Forum Discussion

Lance_Simon_557's avatar
Lance_Simon_557
Historic F5 Account
May 29, 2007

changing the url...do not want a redirect

I'm looking for a way to change a url that comes in from public ip addresses:

 

 

url that comes in from public goes is: http://123.abc.com

 

need it changed to: http://123ext.abc.com

 

 

There is no outside dns available for 123ext.abc.com, so a normal redirect would not work.

 

 

I'm pretty sure this can be d one, but I not sure of the syntax.

 

 

Any assistance would be appreciated.

 

 

Thanks

3 Replies

  • You are asking about changing the host value, not the URI. The format of a URL is the following

    http://[HTTP::host][HTTP::uri]

    http://www.foo.com/foo/bar

    HTTP::host -> www.foo.com

    HTTP::uri -> /foo/bar

    So, for your specific question, you'll need to tweak the Host header. For a host modification, you can do the following:

    when HTTP_REQUEST {
      if { [HTTP::host] eq "123.abc.com" } {
        HTTP::header replace "Host" 123ext.abc.com"
      }
    }

    This will modify the Host header of the HTTP request to the backend server to be "123ext.abc.com" so it will effectively look to the backend server like the request was http://123ext.abc.com/....

    Hope this helps...

    -Joe
  • Lance_Simon_557's avatar
    Lance_Simon_557
    Historic F5 Account
    Joe,

     

     

    I appreciate you reply.

     

     

    How would I combine two rules? I've got this one, that states which pool to go to if coming from the public side:

     

     

    when HTTP_REQUEST {

     

    if { [matchclass [IP::remote_addr] equals $::group_public_websites] } {

     

    pool pool_public_websites

     

    } else {

     

    HTTP::redirect "http://www.abc.com/temp/outage.jsp/"

     

    }

     

    }

     

     

    And yours:

     

     

    when HTTP_REQUEST {

     

    if { [HTTP::host] eq "123.abc.com" } {

     

    HTTP::header replace "Host" 123ext.abc.com"

     

    }

     

    }

     

     

    I'd like to know how you'd go about saying IF the request is coming from the public side AND if the host is 123.abc.com, go to this pool, else here...

     

     

    Thanks again.
  • Try this. I added a missing leading quote to your host header replacement value.

    
    when HTTP_REQUEST {
      if { ([matchclass [IP::remote_addr] equals $::group_public_websites]) and ([HTTP::host] eq "123.abc.com") } {
        HTTP::header replace "Host" "123ext.abc.com"
        pool pool_public_websites
      } else {
        HTTP::redirect "http://www.abc.com/temp/outage.jsp/"
      }
    }