Forum Discussion
Dbow_21284
Nimbostratus
Feb 12, 2008Redirecting back and forth between HTTP and HTTPS virtual servers for the same site
Hello,
I have a site that we are about to use F5 Big-IP LTM to load balance. I am a little green though and I need some assistance with creating iRULES to redirect back and forth between the Virtual Servers (one is port 80 and one is 443).
Our site is mostly port 80, http://mysite.com and all that traffic is fine initially going through the load balancer. This has been tested. However, there is a login component that switches the url to https://mysite.com/default_ssl.aspx and I need to get this traffic redirected to the 443 VS ... right? I haven't been able to find any examples code or criteria that I need to base the redirect on.
Also, after the user logins, they can click on other areas of the site that go back to port 80. So likewise, I need to be able to redirect the traffic via an iRULE back to the http VS too right?
1) Can anyone shed some light on this and verify that I am going in the right direction with this?
2) Does anyone have any ideas on sample iRULE code that I can use/build upon?
3) Should my web developers know what the triggers should be to redirect? ... I am assuming so.
I appreciate your help!
Dbow!
- hoolio
Cirrostratus
You could create a string datagroup (in the GUI under Local Traffic >> iRules >> Datagroup tab) containing the full paths you want accessed only via HTTPS. Then for the HTTP virtual server, use a rule to redirect all requests to these paths to HTTPS. If you only wanted to allow HTTPS requests to the HTTPS VIPs for those paths, you could redirect all others to HTTP using a second rule on the HTTPS VIP.when HTTP_REQUEST { Check if request is to a secure URI if {[matchclass [HTTP::path] equals $::secure_paths_datagroup]}{ Redirect request via HTTPS HTTP::redirect https://[HTTP::host][HTTP::uri] } }
when HTTP_REQUEST { Check if request is not to a secure URI if {not ([matchclass [HTTP::path] equals $::secure_paths_datagroup])}{ Redirect request via HTTP HTTP::redirect http://[HTTP::host][HTTP::uri] } }
- dennypayne
Employee
I'm not clear on what exactly is meant by the "login component" but if the HTML that the server sends back to the client contains the https://mysite.com/default_ssl.aspx link, if the user clicks on that the browser will request the content over 443 by default. The LTM will simply answer from the 443 VS. Likewise for any http links that are embedded in the HTML coming from the https connection. You don't need any redirects for default browser behavior. - Dbow_21284
Nimbostratus
I figured out that the issue I was having was a simple one. - dennypayne
Employee
"Match across" is available in source_addr or cookie persistence. The default cookie persistence without the "match across" option enabled will *not* ensure that the user stays on the same node from 80 to 443. - hoolio
Cirrostratus
I missed that the app was handling the redirects. I thought you were looking to handle the redirects in a rule on the BIG-IP. - Dbow_21284
Nimbostratus
Yeah, I was on the wrong track to begin with when I ran it by F5 Support. They told me I would require an iRULE to redirect 80 and 443 traffic between VS's even if they are on the same site. ... I probably didnt explain it very clearly though. - hoolio
Cirrostratus
Source address persistence with match across virtuals and services enabled should work fine for this. If you test, you can check the persistence records by running 'b persist all show all' via the command line or by checking Statistics >> Persistence in the GUI.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects