Forum Discussion
Ralph_Duane_761
Nimbostratus
May 13, 2005Rookie needs help. iRule url redirection
I am a newbie with BigIP and not much of a coder either. I want to use BigIP to redirect traffic based on the url. If url contains tsa then goto one webpool and if it contains either tsa_test or tsa_train to goto another webpool. The base url is https. The webpools are http.
Can anyone help?
Thanks.
21 Replies
- JRahm
Admin
try this:rule URI_switch { when HTTP_REQUEST { set uri_info [HTTP::uri] if { $uri_info contains "tsa_test" or \ $uri_info contains "tsa_train" } { use pool pool_two } elseif { $uri_info contains "tsa" } { use pool pool_one } else { use pool default } } } - Ralph_Duane_761
Nimbostratus
Thanks, citizen_elah. I am creating this rule thru the BigIP web admin interface. It is working but I had to strip out the section for using pool default. It was complaining that this was undefined when trying to update.
Another question. When typing the https://url/tsa in my browser I have to end the url with another slash (/) or it doesn't find the web page. If I go directly to the web server (which is just using http) I do not need to end the url with a slash. Is there a way to setup the bigip so that I don't need this / at the end of the url.
Thanks. - drteeth_127330Historic F5 AccountA trailing slash should not be required. I was not able to reproduce the problem with 9.0.5. What version are you using?
- Ralph_Duane_761
Nimbostratus
I am running version 9.0.4. - drteeth_127330Historic F5 AccountIs this an iRule problem? Did you include the final else in citizen_elah's example? Do you experience the problem if you set the pool on the virtual server to pool_one and remove the rule? What do the logs on the webserver show? Is BIG-IP truncating the URI somehow? Thanks.
- Ralph_Duane_761
Nimbostratus
I don't think this is a rule problem. Before the rule was in place, I still needed the / at the end of the url to get to the web page. I dod not include the final else condition because when completing the rule, it complained that this was undefined. I have also noticed that goiing to other secure sites that are unrelated to this in any way I have had to use the / at the end of the url. - JRahm
Admin
Is the problem with tsa only, or also with tsa_train and tsa_test?
Alternately, I wonder if you could check for the trailing "/" in the URI, and if it is not present, add it. This assumes that there is no trailing information after the "/", I defer to the experts if that is the case.rule URI_switch { when HTTP_REQUEST { set uri_info [HTTP::uri] if {not {$uri_info ends_with "/"} } { append uri_info "/" } if { $uri_info contains "tsa_test" or \ $uri_info contains "tsa_train" } { use pool pool_two } elseif { $uri_info contains "tsa" } { use pool pool_one } else { use pool default } } } - Ralph_Duane_761
Nimbostratus
citizen, I tried the code to add the / but that caused the pages not to be available whether or not I added the / to the end of the url.
It does need the trailing / on tsa and tsa_test and tsa_train. - JRahm
Admin
Maybe you should back up and do some diagnostic logging at this point:rule URI_switch { when HTTP_REQUEST { set uri_info [HTTP::uri] log "Variable uri_info contents: $uri_info" if {not {$uri_info ends_with "/"} } { append uri_info "/" log "Variable uri_info contents w\/ "\/" appended:" }
Also, check to see if the "/" is a special character in TCL, that might be a problem. - unRuleY_95363Historic F5 AccountDon't forget to check /var/log/ltm as run-time errors are reported there. You are likely getting a run-time error when the page doesn't load. (log also outputs it's messages to /var/log/ltm).
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
