Forum Discussion
redirect to https multiple uri's while letting others pass through
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
- deni_22991
Nimbostratus
Prior to moving these applications behind the F5, they were running behind a Cisco Content Switch. The apps have run for years without these inconsistencies that we are now seeing. I will continue to look into the IIS side of it, but that has not changed with the change from Content Switch to F5.
I have taken out the -glob. - Chris_Miller
Altostratus
Posted By deni on 01/10/2011 04:54 AM
Prior to moving these applications behind the F5, they were running behind a Cisco Content Switch. The apps have run for years without these inconsistencies that we are now seeing. I will continue to look into the IIS side of it, but that has not changed with the change from Content Switch to F5.
I have taken out the -glob.
And now we get the same error but without the redirect happening. Can you please take the iRule off the Virtual just to see whether the error goes away. - deni_22991
Nimbostratus
The iRule has been removed from the Virtual Server. - Chris_Miller
Altostratus
Posted By deni on 01/10/2011 05:56 AM
The iRule has been removed from the Virtual Server.
Thanks! Looks like the site loads fine now so there's quite possibly something in the rule that's causing issues with IIS.From what I've seen, the redirects don't happen without the -glob. Not quite sure why switch didn't work, but whatever.
Let's go back to switch -glob and troubleshoot from there.
Thanks!
- Chris_Miller
Altostratus
Also, I'm adding a bit more logging so if a 403 is thrown, we can get more detail.when HTTP_REQUEST { if { [HTTP::host] equals "appsf5.sd.gov" } { log local0. "User went to http://[HTTP::host][HTTP::uri]" set site [HTTP::uri] switch -glob [string tolower [HTTP::uri]] { "/applications/dp42launchpad*" { HTTP::redirect "https://[HTTP::host]/applications/dp42launchpad/logon.aspx" log local0. "Requested http://[HTTP::host][HTTP::uri] and was redirected to https://[HTTP::host]/applications/dp42launchpad/logon.aspx" } "/applications/st01fastfile*" { HTTP::redirect "https://[HTTP::host]/applications/st01fastfile/login.asp" log local0. "Requested http://[HTTP::host][HTTP::uri] and was redirected to https://[HTTP::host]/applications/st01fastfile/login.asp" } "/applications/gf79biggame*" { HTTP::redirect "https://[HTTP::host]/applications/gf79biggame/login.asp" log local0. "Requested http://[HTTP::host][HTTP::uri] and was redirected to https://[HTTP::host]/applications/gf79biggame/login.asp" } "/applications/gf82*" { HTTP::redirect "https://[HTTP::host][HTTP::uri]" log local0. "Requested http://[HTTP::host][HTTP::uri] and was redirected to https://[HTTP::host][HTTP::uri]" } } } } when HTTP_RESPONSE { if { [HTTP::status] eq "403" } { log local0. "403 for $site }} - deni_22991
Nimbostratus
I added the rule back to the Virtual Server and added the -glob and extra logging. - Chris_Miller
Altostratus
Posted By deni on 01/10/2011 06:08 AM
I added the rule back to the Virtual Server and added the -glob and extra logging.
Redirect appears to be happening but the site doesn't seem to be loading. What are you seeing from logs? - Chris_Miller
Altostratus
Adding a default statement as well.when CLIENT_ACCEPTED { set default_pool [LB::server pool] } when HTTP_REQUEST { if { [HTTP::host] equals "appsf5.sd.gov" } { log local0. "User went to http://[HTTP::host][HTTP::uri]" set site [HTTP::uri] switch -glob [string tolower [HTTP::uri]] { "/applications/dp42launchpad*" { HTTP::redirect "https://[HTTP::host]/applications/dp42launchpad/logon.aspx" log local0. "Requested http://[HTTP::host][HTTP::uri] and was redirected to https://[HTTP::host]/applications/dp42launchpad/logon.aspx" } "/applications/st01fastfile*" { HTTP::redirect "https://[HTTP::host]/applications/st01fastfile/login.asp" log local0. "Requested http://[HTTP::host][HTTP::uri] and was redirected to https://[HTTP::host]/applications/st01fastfile/login.asp" } "/applications/gf79biggame*" { HTTP::redirect "https://[HTTP::host]/applications/gf79biggame/login.asp" log local0. "Requested http://[HTTP::host][HTTP::uri] and was redirected to https://[HTTP::host]/applications/gf79biggame/login.asp" } "/applications/gf82*" { HTTP::redirect "https://[HTTP::host][HTTP::uri]" log local0. "Requested http://[HTTP::host][HTTP::uri] and was redirected to https://[HTTP::host][HTTP::uri]" } default { pool default_pool } } } when HTTP_RESPONSE { if { [HTTP::status] eq "403" } { log local0. "403 for $site } - deni_22991
Nimbostratus
Mon Jan 10 15:00:07 CST 2011 tmm tmm[2048] Rule apps_withssl HTTP_REQUEST: User went to http://appsf5.sd.gov/applications/HC70SBI/LeftFrame.asp
Mon Jan 10 15:00:07 CST 2011 tmm tmm[2048] Rule apps_withssl HTTP_REQUEST: User went to http://appsf5.sd.gov/applications/HC70SBI/TopFrame.asp
Mon Jan 10 15:00:07 CST 2011 tmm tmm[2048] Rule apps_withssl HTTP_REQUEST: User went to http://appsf5.sd.gov/applications/HC54ApprovedProducts/ms.css
Mon Jan 10 15:00:07 CST 2011 tmm tmm[2048] Rule apps_withssl HTTP_REQUEST: User went to http://appsf5.sd.gov/applications/HC70SBI/QueryPage.asp?Startup=TRUE
Mon Jan 10 15:00:07 CST 2011 tmm tmm[2048] Rule apps_withssl HTTP_REQUEST: User went to http://appsf5.sd.gov/applications/HC54ApprovedProducts/images/bk_2.gif
Mon Jan 10 15:00:08 CST 2011 tmm tmm[2048] Rule apps_withssl HTTP_REQUEST: User went to http://appsf5.sd.gov/applications/HC70SBI/bk_3.gif
Mon Jan 10 15:00:59 CST 2011 tmm tmm[2048] Rule apps_withssl HTTP_REQUEST: User went to http://appsf5.sd.gov/applications/gf82/login.asp
Mon Jan 10 15:00:59 CST 2011 tmm tmm[2048] Rule apps_withssl HTTP_REQUEST: Requested http://appsf5.sd.gov/applications/gf82/login.asp and was redirected to https://appsf5.sd.gov/applications/gf82/login.asp
I still cannot get to the https sites, although the redirect does seem to work. It pulls up a page cannot be displayed.
On your code for adding the default statement and pool information, where do I name my pool for the virtual server? Is it where you have server pool? - Chris_Miller
Altostratus
Posted By deni on 01/10/2011 01:05 PM
Mon Jan 10 15:00:07 CST 2011 tmm tmm[2048] Rule apps_withssl HTTP_REQUEST: User went to http://appsf5.sd.gov/applications/HC70SBI/LeftFrame.asp
Mon Jan 10 15:00:07 CST 2011 tmm tmm[2048] Rule apps_withssl HTTP_REQUEST: User went to http://appsf5.sd.gov/applications/HC70SBI/TopFrame.asp
Mon Jan 10 15:00:07 CST 2011 tmm tmm[2048] Rule apps_withssl HTTP_REQUEST: User went to http://appsf5.sd.gov/applications/HC54ApprovedProducts/ms.css
Mon Jan 10 15:00:07 CST 2011 tmm tmm[2048] Rule apps_withssl HTTP_REQUEST: User went to http://appsf5.sd.gov/applications/HC70SBI/QueryPage.asp?Startup=TRUE
Mon Jan 10 15:00:07 CST 2011 tmm tmm[2048] Rule apps_withssl HTTP_REQUEST: User went to http://appsf5.sd.gov/applications/HC54ApprovedProducts/images/bk_2.gif
Mon Jan 10 15:00:08 CST 2011 tmm tmm[2048] Rule apps_withssl HTTP_REQUEST: User went to http://appsf5.sd.gov/applications/HC70SBI/bk_3.gif
Mon Jan 10 15:00:59 CST 2011 tmm tmm[2048] Rule apps_withssl HTTP_REQUEST: User went to http://appsf5.sd.gov/applications/gf82/login.asp
Mon Jan 10 15:00:59 CST 2011 tmm tmm[2048] Rule apps_withssl HTTP_REQUEST: Requested http://appsf5.sd.gov/applications/gf82/login.asp and was redirected to https://appsf5.sd.gov/applications/gf82/login.asp
I still cannot get to the https sites, although the redirect does seem to work. It pulls up a page cannot be displayed.
On your code for adding the default statement and pool information, where do I name my pool for the virtual server? Is it where you have server pool?http://appsf5.sd.gov/applications/HC70SBI/default.asp doesn't work buthttps://appsf5.sd.gov/applications/HC70SBI/default.asp does. Any ideas why that wouldn't work for HTTP?http://appsf5.sd.gov/applications/gf82/login.asp seems to redirect and work fine.You don't need to modify the code at all. The first part sets a variable with the Virtual Server's default pool. Then, I call that variable from the switch statement.Both links were working earlier today when I tried...was the only change you've made today to update the iRule just now?
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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
