Forum Discussion
deni_22991
Nimbostratus
Jan 04, 2011redirect to https multiple uri's while letting others pass through
I am trying to create an iRule that will force ssl on specific multiple URI's under a specific host while letting those that do not need SSL to pass through. I am working on BIG-IP 9.4.7 Build 320.1
I have created a Virtual Server with port 80, created a pool and have added the iRule to the Virtual server. I have a wild card SSL cert that works for our appsf5.com
I have created the following iRule, but it only works once or twice before getting a page not found.
when HTTP_REQUEST
{ if { [HTTP::host] equals "appsf5.com" }{
if { [HTTP::uri] starts_with "/applications/app1" }
{ HTTP::redirect "https://[HTTP::host]/applications/app1/logon.aspx" }
elseif { [HTTP::uri] starts_with "/applications/app2" }
{ HTTP::redirect "https://[HTTP::host]/applications/app2/login.asp" }
elseif { [HTTP::uri] starts_with "/applications/app3" }
{ HTTP::redirect "https://[HTTP::host]/applications/app3/login.asp" }
elseif { [HTTP::uri] starts_with "/applications/app4" }
{ HTTP::redirect "https://[HTTP::host][HTTP::uri]" }
else {HTTP::respond "http://[HTTP::host][HTTP::uri]" }
}
}
56 Replies
- Chris_Miller
Altostratus
Let's add some logging then.when HTTP_REQUEST { if { [HTTP::host] equals "appsf5.com" } { switch [string tolower [HTTP::uri]] { "/applications/app1*" { HTTP::redirect "https://[HTTP::host]/applications/app1/logon.aspx" log local0. "Requested http://[HTTP::host][HTTP::uri] and was redirected to https://[HTTP::host]/applications/app1/logon.aspx" } "/applications/app2*" { HTTP::redirect "https://[HTTP::host]/applications/app2/login.asp" log local0. "Requested http://[HTTP::host][HTTP::uri] and was redirected to https://[HTTP::host]/applications/app2/login.asp" } "/applications/app3*" { HTTP::redirect "https://[HTTP::host]/applications/app3/login.asp" log local0. "Requested http://[HTTP::host][HTTP::uri] and was redirected to https://[HTTP::host]/applications/app3/login.asp" } "/applications/app4*" { HTTP::redirect "https://[HTTP::host][HTTP::uri]" log local0. "Requested http://[HTTP::host][HTTP::uri] and was redirected to https://[HTTP::host][HTTP::uri]" } } } }
Try again and it should log to the LTM section of logs when a redirect is triggered. - deni_22991
Nimbostratus
I have added the logging. I am unable to find the logs it creates. It still does not redirect correctly. Could you explain how I find the log files? - Chris_Miller
Altostratus
If using the GUI, they'll be under system > logs > ltm - deni_22991
Nimbostratus
I am working on BIG-IP 9.4.7 Build 320.1 I am using the GUI. Under System > Logs > I have the choices of System, Packet Filter, Local Traffic, Audit, Application Security and Options.
I chose Local Traffic and there is a list there, but it is just a list and all it has is (I changed the IP address)
Thu Jan 6 09:05:21 CST 2011 F5Name-DMZ-1 bigpipe Completed config sync all operation
Thu Jan 6 09:58:22 CST 2011 F5Name-DMZ-1 mcpd[2458] 01070638 Pool member 111.111.111.11:80 monitor status down.
Thu Jan 6 09:58:22 CST 2011 tmm tmm[2048] 01010028 No members available for pool SDBoardOfNursing_pool
Thu Jan 6 09:58:51 CST 2011 F5Name-DMZ-1 mcpd[2458] 01070727 Pool member 111.111.111.11:80 monitor status up.
Thu Jan 6 12:40:22 CST 2011 F5Name-DMZ-1 bigpipe Completed config sync all operation
Thu Jan 6 12:49:32 CST 2011 F5Name-DMZ-1 bigpipe Completed config sync all operation
Thu Jan 6 12:50:08 CST 2011 F5Name-DMZ-1 bigpipe Completed config sync all operation
Thu Jan 6 12:50:43 CST 2011 F5Name-DMZ-1 bigpipe Completed config sync all operation
Thu Jan 6 13:03:18 CST 2011 F5Name-DMZ-1 bigpipe Completed config sync all operation
Is there some setting in options that I need to set? - Chris_Miller
Altostratus
Local Traffic is indeed the right section.
If this iRule is applied, there's no reason it shouldn't be getting hit and logging messages. Can you describe the steps by which you applied the rule? And also the exact link you're using? - deni_22991
Nimbostratus
I have a Virtual Server set at Port 80. On that Virtual Server, I have applied the iRule by clicking on the Virtual Server in the F5 GUI interface and selecting Resources. In the IRules section, I clicked Manage and added the iRule. I moved this iRule to the top of the list. - Chris_Miller
Altostratus
Good...that's definitely proper.
I'm adding another log statement that should log every single HTTP Request so kindly check the logs again after hitting the Virtual Server with the following rule.when HTTP_REQUEST { log local0. "User went to http://[HTTP::host][HTTP::uri]"if { [HTTP::host] equals "appsf5.com" } { switch [string tolower [HTTP::uri]] { "/applications/app1*" { HTTP::redirect "https://[HTTP::host]/applications/app1/logon.aspx" log local0. "Requested http://[HTTP::host][HTTP::uri] and was redirected to https://[HTTP::host]/applications/app1/logon.aspx" } "/applications/app2*" { HTTP::redirect "https://[HTTP::host]/applications/app2/login.asp" log local0. "Requested http://[HTTP::host][HTTP::uri] and was redirected to https://[HTTP::host]/applications/app2/login.asp" } "/applications/app3*" { HTTP::redirect "https://[HTTP::host]/applications/app3/login.asp" log local0. "Requested http://[HTTP::host][HTTP::uri] and was redirected to https://[HTTP::host]/applications/app3/login.asp" } "/applications/app4*" { HTTP::redirect "https://[HTTP::host][HTTP::uri]" log local0. "Requested http://[HTTP::host][HTTP::uri] and was redirected to https://[HTTP::host][HTTP::uri]" } } } - deni_22991
Nimbostratus
It now logs the first logging "User went to http://[HTTP::host][HTTP::uri]" but does not make it to the logging within each application. So it doesn't seem to be hitting the
switch [string tolower [HTTP::uri]] {
"/applications/app1*"
{ HTTP::redirect "https://[HTTP::host]/applications/app1/logon.aspx"
log local0. "Requested http://[HTTP::host][HTTP::uri] and was redirected to https://[HTTP::host]/applications/app1/logon.aspx" }
I have used iRule Editor and the syntax shows it as correct, but it does not show the log local0. "Requested http://[HTTP::host][HTTP::uri] and was redirected to https://[HTTP::host]/applications/app1/logon.aspx" } in the log. - Chris_Miller
Altostratus
What was the log message when it hit "User went to http://[HTTP::host][HTTP::uri]"? - hoolio
Cirrostratus
As Chris suggests, I'd guess the Host check you have for appsf5.com isn't being matched so the switch statement isn't being hit. Or none of the URI checks in the switch statement are being matched.
Aaron
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
