Forum Discussion
favicon troubles keeps resulting in http 302 redirect
Hi,
We've problems with a website which always asks for the favicon.ico. When it's not to be found the bigip always sends back a 302 redirect and then the session times out. We tried to control this be creating an irule which looks for a 404 and then do a redirect or a 200 content or something. But we somehow keep getting the time-out because of this favicon.
24 Replies
- heskez_36146
Nimbostratus
Hi, I understand this appears to be a little weird, so let me explain.. The purpose of this irule is to redirect users to a sub location www.x.com/north/something. Because that's the location of the application. There are two applications on two locations north and south. www.x.com is actually nothing. Furthermore we want to do a redirect when there are no available pool members to avoid "hard" error messages.
- What_Lies_Bene1
Cirrostratus
OK, understood, however, you have opposing logic in your rule, for instance a path of
would match both of these conditions in the rule. Do you want to redirect or do you want to select a Pool?;/north/index.htmlif { !($RequestedPath starts_with "/n") } { HTTP::redirect "https://x/north/" }and
if { $RequestedPath contains "/north" } { if {[active_members Pool_x-north] > 0 } { pool Pool_x-north - heskez_36146
Nimbostratus
There's is a difference in this irule i didn't explain correctly. The locations are world-north and world-south So the redirect should be something like this:
if { !($RequestedPath starts_with "/world") } { HTTP::redirect "https://x/world-north/" }This is the preferable location above south
After that we want to select a pool if there are active members.
if { $RequestedPath contains "/world-north" } { if {[active_members Pool_x-north] > 0 } { pool Pool_x-north - What_Lies_Bene1
Cirrostratus
Sorry but that would still create a problem. If the path starts with /world, redirect to /world-north, the request comes back in with /world-north, which starts with /world, gets redirected and on...
- heskez_36146
Nimbostratus
What do you suggest?
- What_Lies_Bene1
Cirrostratus
I'm sure I could knock something up pretty quicky, can you just describe in detail exactly what you require please.
- heskez_36146
Nimbostratus
We'd like something as follows:
-> Begin with www.x.com
if someone types www.x.com/north goto www.x.com/north/applicationurl if someone types www.x.com/south goto www.x.com/south/applicationurl if someone types www.x.com/north/ goto www.x.com/north/applicationurl if someone types www.x.com/south/ goto www.x.com/south/applicationurl
if someone types just www.x.com goto www.x.com/north/applicationurl
When there are active pool members in north -> select north pool else -> produce fancy error page When there are active pool members in south -> select south pool else -> produce fancy error page
That's it basically..
- What_Lies_Bene1
Cirrostratus
OK, here you go, it's not too different but I've tidied up the switch and added some returns to prevent any logic clashes, plus added a reject where there's no match;
-REMOVED - CORRECTED BELOW
- heskez_36146
Nimbostratus
Thank you very much for this! Err.. I cannot appy the irule keeps struggeling about this syntax:
else { if { [active_members Pool_www.y.nl] > 0 } { HTTP::redirect "http://www.y.nl/error/" - What_Lies_Bene1
Cirrostratus
Ah, I see the issue, corrected version;
when HTTP_REQUEST { set RequestedPath [string tolower [HTTP::path]] Redirect only if the HTTP path exactly matches one of the following; switch $RequestedPath { "/" - "/north" - "/north/" { HTTP::redirect "https://x/north/applicationurl" Stop processing the iRule here return } "/south" - "/south/" { HTTP::redirect "https://x/south/" Stop processing the iRule here return } } if { $RequestedPath starts_with "/north/" } { if { [active_members Pool_x-north] > 0 } { pool Pool_x-north } elseif { [active_members Pool_www.y.nl] > 0 } { HTTP::redirect "http://www.y.nl/error/" } } elseif { $RequestedPath starts_with "/south/" } { if { [active_members Pool_x-south] > 0 } { pool Pool_x-south } elseif { [active_members Pool_www.y.nl] > 0 } { HTTP::redirect "http://www.y.nl/error/" } } else { Can't serve fancy error page or HTTP path doesn't match Let's reject so clients don't have to wait for a timeout reject } }
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