Forum Discussion
Eric_Frankenfie
Nimbostratus
Jun 25, 2010HTTP Redirects
I am new to iRules and going through baptism by fire.
I would like the following URLs: http://www.qa.ipcws.fiserv.com, http://qa.ipcws.fiserv.com, https://www.qa.ipcws.fiserv.com, https://qa.ipcws.fiserv.com to be redirected to https://qa.ipcws.fiserv.com/cws.web/Login.aspx
Any help would be greatly appreciated!
- Eric_Frankenfie
Nimbostratus
This is what I came up with so far... - Eric_Frankenfie
Nimbostratus
I believe this did the trick for my VS listening on 443 when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "www.qa.ipcws.fiserv.com" } { HTTP::redirect "https://qa.ipcws.fiserv.com/cws.web/Login.aspx" } if { [string tolower [HTTP::host]] equals "qa.ipcws.fiserv.com" } { HTTP::redirect "https://qa.ipcws.fiserv.com/cws.web/Login.aspx" } } I then created a second VS listening on port 80 and configured this iRule when HTTP_REQUEST { if { [TCP::local_port] == 80 }{ HTTP::redirect "https://[getfield [HTTP::host] ":" 1][HTTP::uri]" } } - Eric_Frankenfie
Nimbostratus
Upon further testing this does not work...Any help would be greatly appreciated! - hoolio
Cirrostratus
Hi Eric,HTTP_REQUEST { HTTP::redirect "https://[getfield [HTTP::host] ":" 1][HTTP::uri]" }
when HTTP_REQUEST { Check the requested host set to lowercase switch [string tolower [HTTP::host]] { "www.qa.ipcws.fiserv.com" - "qa.ipcws.fiserv.com" { Matched the host check, send a 301 with the new location HTTP::respond 301 Location "https://qa.ipcws.fiserv.com/cws.web/Login.aspx" } default { Take some default action? } } }
- Eric_Frankenfie
Nimbostratus
I removed the iRule from the HTTPS VS deleted the iRule, recreated the iRule with a different, and applied the iRule to the VS. However, the redirect is not working when I navigate to https://www.qa.ipcws.fiserv.com/. I am I missing any thing? - Eric_Frankenfie
Nimbostratus
Thanks! I just tested the HTTP to HTTPS redirect and that is functioning...Still trying to get the redirect from www.qa.ipcws.fiserv.com to qa.ipcws.fiserv.com to work. - Eric_Frankenfie
Nimbostratus
I just captured the traffic in Wireshark to determine if the Redirect was occurring. I did not see the redirect, but it could be due to the encrypted packets. - Eric_Frankenfie
Nimbostratus
I am currently running version 9.4.8. I check to see if there were any known issues, but I could not find any. - hoolio
Cirrostratus
Can you try using a browser plugin to view the unencrypted HTTP requests and responses? You can use HttpFox for Firefox or Fiddler for IE.when HTTP_REQUEST { log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] request to [HTTP::host][HTTP::uri]" Check the requested host set to lowercase switch [string tolower [HTTP::host]] { "www.qa.ipcws.fiserv.com" { Matched the host check, send a 301 with the new location log local0. "[IP::client_addr]:[TCP::client_port]: Matched www.qa.ipcws.fiserv.com, redirecting to login page" HTTP::respond 301 Location "https://qa.ipcws.fiserv.com/cws.web/Login.aspx" } "qa.ipcws.fiserv.com" { Matched the host check, send a 301 with the new location for requests to / if {[HTTP::uri] eq "/"}{ log local0. "[IP::client_addr]:[TCP::client_port]: Matched qa.ipcws.fiserv.com and /, redirecting to login page" HTTP::respond 301 Location "https://qa.ipcws.fiserv.com/cws.web/Login.aspx" } } default { Take some default action? log local0. "[IP::client_addr]:[TCP::client_port]: No match, doing nothing" } } }
- Eric_Frankenfie
Nimbostratus
So, it appears that the redirect is happening...but it is happening AFTER the SSL handshake. So users are presented the SSL certificate error and then if you click continue, the redirect occurs and the correct page is displayed. Is there a way to get the redirect to occur before the SSL handshake so the users are not presented with the SSL name mismatch?
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