How do I redirect my site from http to https using the load balancer

How do I redirect my site from http to https using the load balancer
0

#1

Hi, I've been told to make a redirect from http://abc.com/ to https://abc.com/. Can anyone write an iRule for that?


#2

Hi!


With the requirements you've specified there is an inbuilt iRule that'd accomplish exactly what you need.


You can find it here:

/Common/_sys_https_redirect


/Patrik


#3

hey , im new here but i hope this could help

there are a few methods

check this links for what suites you

https://devcentral.f5.com/questions/irule-to-redirect-http-and-https-to-https-over-port-8888-52691

https://devcentral.f5.com/questions/http-to-https-irule



#4

See https://support.f5.com/csp/article/K26312346

different versions have different to do this.


#5

Annette,

Do not write a IRULE for this simple task. Even though this redirect will not truely tax the F5 by itself it will due to the nature of IRULES spin off anoher thread that is unneeded. The best way to handle this would be to use a LTP(Local traffic Policy). With any version after 11.x you can do this and it is best to use LTP if you uare not doing heavy content manipulation. I am leaving you a link to review and assist in creating a simple LTP redirect policy.


#6
when HTTP_REQUEST {

    HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]"

}

#7

I used policy mentioned by Annette.

But the real servers have to listen on both port 80 and 443. Is it possible for the real server only to listen on port 443 ?


#8

That's an easy irule, but F5 recommends that you use a policy for that instead. Due to the way the code is compiled policies perform much better. Policies can evaluate all the conditions in parallel, while irules are ordered.


F5 ha an article that describes how to create an HTTP to HTTPS policy that can be viewed here.


Furthermore there are built in irules fresh out of the box that you can use, rather than creating your own. If you navigate to local traffic/irules and then look at the irules that begin with _sys you should find one that is for http_to_https redirects and it should look something like this:


when HTTP_REQUEST {
       HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
    }


Hope that helps.


#9

We have to set a canonical URL for HTTP and https, If search engines already aware of it, then why they do not fix it. I had faced a lot of problem with my Lenovo solution center.