Forum Discussion
Matt_Mueller_10
Nimbostratus
Dec 22, 2004Help with removing certain header information from URI
Hello,
We're in the initial setup phase, and are having problems with our iRule. This is what we have so far....
Basically, the customer opens a weblink, lets say www.customercenter.com then they add a /webcentral followed by their customer name /customer1. So the entire string would look like:
www.customercenter.com/webcentral/customer1
With this iRule, we're automatically adding a /archibus to the URI, since that is the virtual directory, and the /customer1 is the company name which directs them towards a pool. The following iRule successfully redirects towards a pool, and adds the /archibus, but it also appends the /webcentral/customer1 at the end, so the string which gets sent to the webserver is:
www.customercenter.com/archibus/webcentral/customer1
For the webserver to work, the string it requires is just www.customercenter.com/archibus
What could we do to modify the iRule so that it successfully appends the /archibus, then removes the /webcentral, and also redirects based on whichever /customer gets entered, then removes that /customer from the string as well?
Thanks for any help
when HTTP_REQUEST {
if {( [HTTP::uri] starts_with "/webcentral" ) } {
HTTP::uri "/archibus[HTTP::uri]"
}
if { [HTTP::uri] contains "/customer1" } {
pool customer1
} elseif { [HTTP::uri] contains "/customer2" } {
pool customer2
} else {
pool Supporthomepage
}
}
- There are several ways you can approach this. You could change your code a bit to not do the HTTP rewrite until you have evaluated all of the cases and use a variable to store the pool name like this:
when HTTP_REQUEST { set def_pool "Supporthomepage" if { [HTTP::uri] starts_with "/webcentral" } { if { [HTTP::uri] contains "/customer1" } { set def_pool "customer1" } elseif { [HTTP::uri] contains "/customer2" } { set def_pool "customer2" } HTTP::uri "/archibus" } pool $def_pool }
- rapmaster_c_127Historic F5 AccountThere's no need for a temporary variable. One thing to note about iRules in 9.x is that they're a full-blown programming language, and the "pool" command is simply that - a command. There's no implied termination of evaluation upon calling it.
rule adsif5 { when HTTP_REQUEST { if {[HTTP::uri] contains "/customer1"} { pool customer1 } elseif {[HTTP::uri] contains "/customer2"} { pool customer2 } else { pool Supporthomepage return } if {[HTTP::uri] starts_with "/webcentral"} { HTTP::uri "/archibus" } } }
- Matt_Mueller_10
Nimbostratus
Thanks Joe and Raja for the responses. - Matt_Mueller_10
Nimbostratus
Just wanted to clarify from last post. Does anyone have any ideas as to why when I enter http;//192.168.150.225/webcentral/customer1 does it not redirect to the pool apparently, but when I type http://192.168.150.225/customer1 it does? Apologies for being a little slow on the uptake here... - drteeth_127330Historic F5 AccountI tested the rule from rapmaster_c and it seems to work fine for me. I recommend using the log command to log the original [HTTP::uri]. Is there any chance that the customer name is part of the querystring?
- Matt_Mueller_10
Nimbostratus
Dr Teeth, - bl0ndie_127134Historic F5 AccountYou can log directly from iRule without any change in the gui. Please refer to the following syntax and example.
log [.]
"alert" "crit" "debug" "emerg" "err" "info" "warning"
"user" "syslog" "local0" "local1" "local2" "local3" "local4" "local5" "local6" "local7" "uucp" "authpriv", "cron" "daemon" "ftp" "kern" "lpr" "mail" "mark" "news" "ntp" "security"
log local0.info
- Matt_Mueller_10
Nimbostratus
when HTTP_REQUEST { if {[HTTP::uri] contains "/customer1"} { pool Customer114.i } elseif {[HTTP::uri] contains "/customer2"} { pool Customer214.i } else { pool Defaulthomepage return } if {[HTTP::uri] starts_with "/webcentral"} { HTTP::uri "/archibus" } log local0.info }
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