Forum Discussion

davidq_20688's avatar
davidq_20688
Icon for Nimbostratus rankNimbostratus
Jun 06, 2011

HTTP Profile for re-direct

Hi All,

 

 

The company I work for has requested we set up a virtual server, which will effectively redirect all incoming HTTP requests.

 

 

 

We have set up a http profile to do this job, however, the redirect is not working as expected.

 

 

 

The virtual server is instead appending the url (of the desired redirect site), to the original url.

 

 

 

Would any of you be able to advise why this is occuring?

 

 

 

Any help would be much appreciated.

 

 

 

Thanks.

 

7 Replies

  • may we see the http profile config?

     

     

    b profile (profile name) list
  • Sorry for the belated reply.

     

     

    The profile config (using the b profile xxx list command) is:

     

     

    profile http xxx_http_profile {

     

    defaults from http

     

    fallback "xxx.html"

     

    }

     

     

    Fairly simple I know, but the objective is also fairly simple.

     

     

    So, any ideas?

     

  • You are doing it right I think, but you may need a redirect irule to redirect based on the uri entered if you want to redirect to a different hostname, otherwise the LTM will simply use the same hostname and append, as you have discovered.

     

     

    So if you are using fallback.html in the profile, add an irule like:

     

     

    when HTTP_REQUEST {

     

    if {([HTTP::uri] eq "fallback.html") } {

     

    HTTP::redirect "http://www.fallbackhost.com/fallback.html"

     

    }

     

    }
  • when pool is down, what is output of the folllowing command?

     

     

    curl -i http://vip/
  • What you're seeing is expected browser behavior.

     

     

    If you specify a local URI for a redirect, the browser will automatically append that redirect location to the current URL. If you want the client to make a request with the same protocol (http or https) to the same FQDN but with a new path of /fallback.html, you should specify the fallback host as /fallback.html. This doesn't follow the exact requirements of RFC2616 but it works.

     

     

    If you want to replace the host in the redirect, you will need to specify a full URL like http://www.example.com/fallback.html.

     

     

    Aaron
  • What you're seeing is expected browser behavior.

     

     

    If you specify a local URI for a redirect, the browser will automatically append that redirect location to the current URL. If you want the client to make a request with the same protocol (http or https) to the same FQDN but with a new path of /fallback.html, you should specify the fallback host as /fallback.html. This doesn't follow the exact requirements of RFC2616 but it works.

     

     

    If you want to replace the host in the redirect, you will need to specify a full URL like http://www.example.com/fallback.html.

     

     

    Aaron