Forum Discussion
Jace_45978
Nimbostratus
Oct 06, 2009moving redirects from server to F5 irule
I have been tasked with putting irule on F5 which should do what the server does for redirects. Conditions from 80 to 443 or from 443 to 80
How would this translate into f5 lingo?
anything to get me rolling is much appreciated!!!
if hitting the VIP on port 443:
code from web server:
RewriteCond %{SERVER_PORT} =443
RewriteCond %{REQUEST_METHOD} !^POST$
RewriteCond %{REQUEST_URI} /DealerNetwork/(.*)\.do(.*) [OR]
RewriteCond %{REQUEST_URI} /DealerNetwork/category/(.*)
RewriteCond %{THE_REQUEST} /DealerNetwork/login.do(.*)logout [OR]
RewriteCond %{REQUEST_URI} !/DealerNetwork/login.do(.*)
RewriteCond %{REQUEST_URI} !/DealerNetwork/registration.do(.*)
RewriteCond %{REQUEST_URI} !/DealerNetwork/forgotPasswd.do(.*)
RewriteCond %{REQUEST_URI} !/DealerNetwork/showProfile.do(.*)
RewriteRule ^/(.*) http://%{SERVER_NAME}/$1 [R,L]
Login, profile and registration pages should be secure. Logout is an exception
of login.do:
RewriteCond %{HTTPS} =off
RewriteCond %{SERVER_PORT} =80
RewriteCond %{REQUEST_METHOD} !^POST$
RewriteCond %{THE_REQUEST} !/DealerNetwork/login.do(.*)logout
RewriteCond %{REQUEST_URI} /DealerNetwork/login.do(.*) [OR]
RewriteCond %{REQUEST_URI} /DealerNetwork/registration.do(.*) [OR]
RewriteCond %{REQUEST_URI} /DealerNetwork/forgotPasswd.do(.*) [OR]
RewriteCond %{REQUEST_URI} /DealerNetwork/showProfile.do(.*)
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
anything to get me rolling is much appreciated!!!
4 Replies
Sort By
- The_Bhattman
Nimbostratus
To handle redirects there are a number of ways to handle this.when HTTP_REQUEST { if { ([HTTP::host] eq "www.something.com") and ([TCP::local_port] eq "80") and ([HTTP::method] eq "POST"}) } { switch -glob [HTTP::uri] { "/DealerNetwork/login*" - "/DealerNetwork/registration.do*" - "/DealerNetwork/forgotPasswd.do*" - "/DealerNetwork/showProfile.do*" { HTTP::redirect "https://[HTTP::host][HTTP::uri]" } } } }
- Jace_45978
Nimbostratus
thanks yes I believe this will get me going... for https to http we will be loading the CERT onto the LTM I will be testing with this soon. - hoolio
Cirrostratus
More generally, here are a few commands which correspond to the values you had in the apache rewrite rules: - Jace_45978
Nimbostratus
Thanks! This worked like a charm....
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