redirection from http to https

Help required to setup a redirection.

Requirment: client accesss the website http://www.abc.co.uk we want to redirect them to https://www.abc.co.uk Solution: I find an easiest and effiecent way is to use HTTP class profile rather than an irule for this redirection. I am confuse on this point

https://[getfield [HTTP::host] “:” 1][HTTP::uri]

What should exactly I write e.g

https://[getfield [HTTP::abc.co.uk] “:” 1][HTTP::uri]

is it correct ?

I am following below solution artical 404 Page not found | BIG-IP Documentation

/ Insert12

Insert12,

Leave it as it’s stated in the sol.

HTTP::host and HTTP::uri are commands that the f5 will use to query the actual host/uri. So HTTP::host will return www.abc.co.uk, for example.

Rgds N

You should write it exactly as it is in the reference document.

Note: The [getfield [HTTP::host] “:” 1] function above extracts the hostname from the host header and, if a non-standard port is specified, removes the port from the host header.

https://[getfield [HTTP::host] ":" 1][HTTP::uri]

By the way, there’s already a built-in HTTP-to-HTTPS redirect iRule on the BIG-IP called “sys_https_redirect”.

Thanks Nathan..

You should use http class (pre-v11.4) or a policy (v11.4+) to redirect http->https instead of an iRule unless you are doing something special on the http vip.

Hi,

I have tested this HTTP class for a redirection and a built in irule. In both cases redirection sucessfully works but www. is missing or strip out when it redirect to https.

e.g Before redirection http://www.abc.co.uk

after re-direction https://abc.co.uk

we want thisshould remain as https://www.abc.co.uk

Is there any thing else I need to check for this one ?

/ Insert12

What happens if you view the http logs in fiddler/httpfox? Does this tell you anything interesting?

The HTTP::host command will interrogate the host header and neither the class profile/irule will amend this or strip away the www.

N

by looking live header log , this shows redirection sucessfully but there is message

HTTP/1.1 301 Moved Permanently

Server: abc-exy

Location: http://abc.co.uk/ e.g

https://www.abc.co.uk/

GET / HTTP/1.1 Host: www.abc.co.uk

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8 Accept-Language: en-US,en;q=0.5

Accept-Encoding: gzip, deflate DNT: 1 Connection: keep-alive

HTTP/1.1 301 Moved Permanently

Date: Fri, 23 Aug 2013 10:41:48 GMT Server: abc-exy

Location: http://abc.co.uk/

Content-Length: 243 Content-Type: text/html; charset=iso-8859-1 Keep-Alive: timeout=2, max=100 Connection: Keep-Alive

Does this means server is stripping www ?

Perhaps, I’d check the server config. N

HTTP/1.1 301 Moved Permanently Date: Fri, 23 Aug 2013 10:41:48 GMT Server: abc-exy Location: http://abc.co.uk/

i agree with nathan. it is redirected to abc.co.uk by pool member/server.