cancel
Showing results for 
Search instead for 
Did you mean: 

URL Host rewrite then pool selection based on URI

WilliamC
Nimbostratus
Nimbostratus

I have a iRule that directs traffic to specific pools based on the URI.

I am now needing to rewrite the original host part of the URL then allow for the switch statement to direct to the correct pool

 

I am attempting the following code but it does not seem to rewrite the host when going to pool A.

 

when in the browser and going to bob.com/tobee, the URL still shows as bob.com/tobee.

If I go to bob.com/nottobee then the URL changes to www.bob.com/nottobee

 

when HTTP_REQUEST {

if { [HTTP::host] equals "bob.com" } {

HTTP::header replace "Host" "www.bob.com"

}

switch -glob -- [string tolower [HTTP:uri]] {

"/tobee*" {

pool pool_A

}

"nottobee" {

pool pool_B

}

}

}

3 REPLIES 3

Simon_Blakely
F5 Employee
F5 Employee

Your question isn't very clear.

 

Changing the HTTP Host header has no impact on the URL displayed in the browser - it just reflects the address of the page currently being displayed.

 

Changing the host header in HTTP_REQUEST may change the content delivered by the pool member, if the pool member is serving multiple sites distinguished by Host name.

 

However, if the pool member returns a redirect, it may redirect to the host specified in the Host header, which will change the address in the browser bar:

 

browser requests http://bob.com/tobee

pool_A member responds with a 200 OK

- browser bar displays bob.com/tobee

 

browser requests http://bob.com/nottobee

pool_B member responds with a 302 Redirect to http://www.bob.com/nottobee/

- browser bar now displays www.bob.com/nottobee/

 

Use the Browser developer tools Network tab to determine if multiple requests are being made for each of these cases.

Beaker
Cirrus
Cirrus

If you are wanting the URL in the browser to change then you should set the DNS of www.bob.com to the same VIP then set up the irule to redirect the host bob.com to www.bob.com then do context path routing.

 

Replacing the host header just changes what the pool members see as the host name, it does not change the URL.

WilliamC
Nimbostratus
Nimbostratus

Thank you both for your replies, I am still very new to networking so have a hard time phrasing.

 

Beaker, I agree with your statement on the redirect and have put that in our test environment and letting our end users run it through. So far so good 🙂

 

Thanks again!