Forum Discussion
greg_chew_11034
Nimbostratus
Sep 01, 2005http::redirect and http::close and not closing the session.
Hey all.
I am trying to do a redirect to www.foo.com/test.
HTTP/1.0 302 Found
Location: http://www.foo.com/browse/home.html
Server: BIG-IP
Connection: Keep-Alive
Content-Type: text/html
Content-Length: 0
This redirect works fine, but in the same browser, if you do a www.foo.com/gohere, i get in my host header
GET /gohere HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
Host: www.food.com
Connection: Keep-Alive
it seems that it's bypassing the f5 altogether and my irule set and tries to look for a directory called /gohere.
thoughts?
i have tried using HTTP::close before and after my redirect to no avail.
- greg_chew_11034
Nimbostratus
rule foo_uris_rule_v2 { when HTTP_REQUEST { set host [string tolower [getfield [HTTP::host] ":" 1]] set uri [string tolower [HTTP::uri]] set matchstring [substr [substr $uri 1 "?"] 0 "/" ] if { $matchstring == "" } { set matchstring $host$uri } else { set matchstring $host/$matchstring } set redstring [findclass $matchstring $::foo_uris_list " " ] set query_src [findstr [HTTP::uri] "?src=" 5 "&" ] if {$query_src == ""} { set query_src [findstr [HTTP::uri] "&src=" 5 "&" ] } log local0. "query_src = $query_src" set query_trk_src [findstr [HTTP::uri] "trk_src=" 8 " " ] log local0. "query_trk_src = $query_trk_src" if { $query_src != "" } { set redstring $redstring&src=$query_src } if { $query_trk_src != "" } { set redstring $redstring&trk_src=$query_trk_src } if {$redstring eq ""} { if { $host != "www.foo.com" and $host != "foo.com"} { set element [findclass "foo.com/" $::foo_uris_list " " ] log local0. "Defaulting subdomain to foo.com" } } if {$redstring != ""} { log local0. "redirecting to $redstring" HTTP::close HTTP::redirect $redstring HTTP::close event disable all } } }
- unRuleY_95363Historic F5 AccountOk, I think I know what the problem is... The logical expression operators have very high precendence, and as a result have confused many, many people. In your host check:
It's very likely that the "and" is getting done differently than you expect. I will add some parenthesis to show you the way it is likely being interpreted:if { $host != "www.foo.com" and $host != "foo.com" }
As you can see, this would definitely produce a weird and unexpected outcome.if { ($host != ("www.foo.com" and $host)) != "foo.com" }
and see if that doesn't help straighten out the problem.if { ($host != "www.foo.com") and ($host != "foo.com") }
- greg_chew_11034
Nimbostratus
When HTTP::close is before the HTTP::redirect, - unRuleY_95363Historic F5 AccountAlso, I really don't think you should need to do the "event disable all" since this connection should really be closing. If for some reason, the connection is not being closed, no rule events will be triggered. Instead of doing an "event disable all", maybe you should do something like set a variable that says you are done. Something like this:
when CLIENT_ACCEPTED { set http_closed 0 } when HTTP_REQUEST { if { $http_closed } { log "Hey, this connection should be closed!" reject } ... if { ... } { HTTP::redirect http://www.foo.bar.com/newuri set http_closed 1 } }
- unRuleY_95363Historic F5 AccountYou really shouldn't need the HTTP::close with the HTTP::redirect as that is supposed to be the behavior of the redirect.
- greg_chew_11034
Nimbostratus
when the HTTP::close is in the irule, i get this in the ltm log. - unRuleY_95363Historic F5 AccountIn looking closer at your rule, the problem may very well be that a redirect is not happening when you expect it. I would suggest adding a bunch of log statements to help debug the logic and control flow of your rule. (For example, if $redstring == "" you set element and then never redirect - this is the path that the www.foo.com/gohere url would take, so it's not surprising that it gets load-balanced to a server in the pool that then doesn't know about it).
- greg_chew_11034
Nimbostratus
i checked the code and i am just defining $redirect, but there's only one http::redirect at the end, and the $redstring is what's being redirected. it's just that in real life, i try this scenario - unRuleY_95363Historic F5 AccountDid you ever take the "event disable all" out and verify that in fact the browser was reusing the same connection after the redirect? I'm not sure what your rationale is behind disabling all future rule event processing after the redirect. If the browser determines that it later has a request to the same ip address as a connection it already has open, then why does it need to use a new connection? As long as it redirects the next request also... ???
- greg_chew_11034
Nimbostratus
i did try taking the event disable all out of the config and it broke some of the logic.
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