Forum Discussion

Mic_108850's avatar
Mic_108850
Icon for Altostratus rankAltostratus
May 10, 2010

host header presented to origin server

Hello,

 

 

I have one server (x.x.x.x) in a "pool1"

 

i'm using a virtual server "VS1" calling this "pool1"

 

i created a web_app and a class_profile attache to the VS1.

 

 

the origin server (x.x.x.x) is using virtual host. This is one of the virtual host accepted: "game.domain.com"

 

 

This is my goal:

 

Client (http://testgame.domain.com) > cache.mydomain.com (VS1 Ip) > x.x.x.x (pool1)

 

 

How to present game.domain.com to the origin server when a client is calling testgame.domain.com ?

 

4 Replies

  • Hi Mic,

    You can use an iRule like ProxyPass to proxy a web app internally as a different one externally. I don't know how such an iRule would interact with Web Accelerator though, so you might see if anyone else has suggestions.

    http://devcentral.f5.com/wiki/default.aspx/iRules/proxypass (v9.x)

    http://devcentral.f5.com/wiki/default.aspx/iRules/proxypassv10 (v10.x)

    Or if it's really just a matter of rewriting the host header, you can use a simple iRule like this:

    
    when HTTP_REQUEST {
    
        Replace the Host header with game.domain.com
       HTTP::header replace Host "game.domain.com"
    }
    

    Aaron
  • Thanks Aaoron

    and if i have 2 different requested domains i have to present 2 different hostname to the origin dependind of the requested host, can i use an irule like this:

    when HTTP_REQUEST {
      if { [HTTP::header "Host"] eq "game1.domain.com" }  { 
        HTTP::header replace Host org-game1.domain.com
      } 
      if { [HTTP::header "Host"] eq "game2.domain.com" }  { 
        HTTP::header replace Host org-game2.domain.comm
      }
    } 

    is the syntax correct?
  • That should work to rewrite the Host header based on what the client requested. You could also use a switch statement:

    
    when HTTP_REQUEST {
       switch [string tolower [HTTP::header "Host"]] {
          "game1.domain.com" { 
             HTTP::header replace Host org-game1.domain.com
          }
          "game2.domain.com" { 
             HTTP::header replace Host org-game2.domain.com
          }
       }
    }
    

    Aaron