Forum Discussion

bdragna_8791's avatar
bdragna_8791
Icon for Nimbostratus rankNimbostratus
Feb 25, 2008

HTTP Redirect/Rewrite iRule question

I'm kind of new to this, so I'm not even sure if what I'm trying to do is possible or if I'm going about it all wrong.

When the client's web browser makes a request to "host.domain.com" I want the browser to redirect to a different website called "domain.domainnew.com", but I want the client web browser to continue showing the original domain "host.domain.com" in the address bar.

I'm assuming this would require a redirect to "domain.domainnew.com" and then replace/rewrite the host header during the HTTP Response with the original domain "host.domain.com".


when HTTP_REQUEST {
    set domain [getfield [HTTP::host] "." 2]
    set host [HTTP::host]
    set uri [HTTP::uri]
  
    if  { not ($domain equals "domainnew") } {  
    HTTP::redirect https://$domain.domainnew.com$uri }
}
when HTTP_RESPONSE {
      HTTP::header replace Host "www.domain.org"
      log local0. "Host header replaced: [HTTP::host]"      
}

Any help would be appreciated.

I'm logging for HTTP Request and Response information and it looks like it's working from the log information, but the client web browser address bar does not continue to show the original domain.

3 Replies

  • If you send a redirect to the new domain, the client's browser will update when they make a request to the new domain. If you rewrite the Host header value and send it to the server in the pool, the BIG-IP will proxy the request and the change will be transparent to the client.

     

     

    Check out Kirk's proxypass rule in the CodeShare for a very complete solution which handles the Host header rewriting as well as the response headers/content.

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/proxypass (Click here)

     

     

    Aaron
  • I've worked with the ProxyPass iRule a little bit and it's pretty slick, but a lot of it's over my head and I'm not sure if it addresses my particular issue.

     

     

    I need two things to happen, and both of them are between the F5 and the client web browser. I need the client web browser to connect to a particular https web address with no certificate errors, while displaying a different web address in the address bar of the browser.

     

     

    Let me give some more details:

     

     

    Let's say I have two virtual servers receiving http and https requests for www.abc.com, and both are associated with the same server pool. Requests are either http or https based on links within the website and are not redirected from http to https by the F5. But when a https request is received I would like to redirect the client browser from "HTTPS://www.abc.com" to "HTTPS://abc.xyz.com" where both domains point to the same F5 virtual server address and "xyz" is a known constant. The reason for all this trouble is because the SSL certificate being hosted on the F5 is for the domain "abc.xyz.com". I would like the client browser to connect to "HTTPS://abc.xyz.com" without any certificate error or name mismatch messages, but still show "HTTPS://www.abc.com" in the client web browser address bar.

     

     

    Again, what I'm asking might not be possible, but if it is I'd love to know how.

     

     

     

    -bdragna
  • Hi,

     

     

    I don't think that may be possible.

     

     

    Your browser request a specific host and if you want to avoid any mismatch message about the domain between and the browser and the VS you'll need to send a certificate with the same host than the one in the browser address bar.

     

     

    There is no way for me to bypass this restriction without creating a good certificate

     

     

    HTH