2

I have just started to work with F5's Big-IP and I have a question about iRules and HTTP redirects. We are moving to offload our SSL from our web servers and onto the F5, our application as it stands enforces a number of pages on our site to only run in HTTPS. I want to move this from the APP and onto the F5 but I have not been able to figure our how, so as an example I would want anyone trying to login in to be forced to use HTTPS e.g. http://"mysite"/login.aspx = https://"mysite"/login.aspx.

I have done some google searches that have come up with some good info on this but I have yet to find what I am looking for, if anyone has done this and wishes to share this with me that would be great

2 Answers 2

6

There are multiple ways you can use iRules to perform HTTP redirects.

The DevCentral HTTP to HTTPS Redirect Wiki Page has a list of examples (and if you search the site, you'll find many other examples and discussions on how to do more complex redirects with iRules).

In your example, the iRule would simply be:

1 when HTTP_REQUEST {
2 HTTP::respond 301 Location "https://[getfield [HTTP::host] : 1][HTTP::uri]"
3 }

Apply this to the virtual server (the HTTP VS, not the HTTPS VS or you'll create an infinite redirect loop ;-)) and you should be good to go.

2
  • Hi Lori, thank you for the answer. We don't allow signatures/taglines (serverfault.com/faq#signatures) so I edited that out. Hope you don't take offense are we are happy to have representatives from vendors providing technical answers. May 31, 2012 at 13:57
  • Hi, thanks for this but is not completely what I am after. The example you have given does it for all HTTP traffic but I only what this to happen on some pages and not the entire site. I need to be able to write a rule that will look for <URL>/login.aspx and only redirect that page to HTTPS. Thanks for the link to the F5 wiki I am going to have a look though that to see if I can do what I am after.
    – djo
    May 31, 2012 at 23:45
2

I have figured out how to do what I want

_when HTTP_REQUEST {
    if { [string tolower [HTTP::uri]] starts_with "/login.aspx" } {
        HTTP::respond 302 Location "https://[getfield [HTTP::host] : "1"][HTTP::uri]"_
    }
}

Thanks for the help though, it lead me in the right direction.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .