Currently I have a url split between several pools depending on uri portion. How would I modify the Irule to insert a uri if none is present?Any help would be appreciated…
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] starts_with “/abc”} {
Unless I’m mis-interpreting the request, the HTTP::respond command isn’t going to produce the desired results. The HTTP::respond command is going to send a response to the client, whereas I believe what xf6svrb is looking for is to modify the client’s originally requested URI, if it’s empty, to contain “ghi”. Is that correct?
If so, you’d want logic something like this:
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] starts_with "/abc"} {
pool mywebsite.com-abc
} elseif { [string tolower [HTTP::uri]] starts_with "/def"} {
pool mywebsite.com-def
} else {
if { [string length [HTTP::uri] < 2] } {
HTTP::uri "/ghi/"
}
pool mywebsite.com-ghi
}
}
thanks for the input but I must be doing something wrong. The first way with the 301 the irule took and I was able to insert it in the rule. It did not work as far as responding back to the browser, I just got the usual message of 403 forbidden. The second attempt I made would not allow me to add the < 2 command as the irule wouldn’t except the syntax. I tried a combination of the two with respect to the uri.
Ths syntax error is
line 2: [wrong args] [string length [HTTP::uri] < 2]
Sorry I tried a couple different thing and they don’t seem to be working…
Thanks, that corrected the syntax error I was seeing and should have picked up on! This didn’t append the /ghi/ like expected. I changed the rule to have just this in and still didn’t get it to work.
when HTTP_REQUEST {
if {[string equal [HTTP::uri] {/}] } {
HTTP::uri {/ghi/}
}
}
If it doesn’t, change the “Type” configured for the virtual server to “Standard” and retry.
Also, was it clear to you that this causes BIG-IP to modify the HTTP request passing from the user to the server? Therefore, even though the content is coming from http://www.example.com/ghi/, the user’s web browser will still show http://www.example.com/ in the address field.
No, this didn’t seem to work ever though this is my only entry in the Irule
when HTTP_REQUEST {
if {[string equal [HTTP::uri] {/}] } {
HTTP::uri {/ghi/}
}
}
It still won’t append it??? I would then expect at the browser to see a redirect to the actual login page as there are redirects on the web server that would redirect to the login.jsp. I am now stumped!!! The VS type = standard.
The only way to test this is to include logging statements on the BIG-IP as well as web server logging on the backend server.
when HTTP_REQUEST {
log local0. "URI: [HTTP::uri]"
if { [HTTP::uri] equals "/" } {
log local0. "URI is empty, changing to http://[HTTP::host]/ghi..."
HTTP::uri "/ghi/"
} else {
log local0. "URI is not empty, leaving alone..."
}
}
Then look in the /var/log/ltm file on the BIG-IP to make sure that the iRule is functioning correctly. If you see that is the case, then you’ll have to look at the web server’s log (or a packet trace) on the web server to verify the GET request is now “/ghi/”. If your webserver is still showing a “GET / …” then you’ll have to contact Technical support as this is very basic functionality and you are using the iRule correctly.