Forum Discussion
sunnyman67_1367
Nimbostratus
Nov 03, 2013URL rewrite through iRule
Hi Guys,
i have one "Performance (HTTP)" virtual server on F5-1600 series, and i want to change the URL "http://www.abc.com" to "http://partner.abc.com/xyz". i have tried all below scripts :
1-
...
- Nov 11, 2013
Hi Sunnyman,
This will work;
if { [IP::addr [IP::client_addr] equals 1.1.1.1] || [IP::addr [IP::client_addr] equals 1.1.1.2} { SNAT with 1.1.1.100 snatpool VM_SNAT_POOL_1_1_1_100 } elseif { [IP::addr [IP::client_addr] equals 1.1.1.11] || [IP::addr [IP::client_addr] equals 1.1.1.12} { SNAT with 1.1.1.100 snatpool VM_SNAT_POOL_1_1_1_200 }But that's not a very scalable way of doing it if your list is going to grow. If it's going to grow then use an address datagroup, with values snatpool names, which you can use like this
snatpool [class match -value [IP::remote_addr] equals dg_sunnyman_snatpools]or more correctly;
set snatpool [class match -value [IP::remote_addr] equals dg_sunnyman_snatpools] if {$snatpool ne "") { snatpool $snatpool }
IheartF5_45022
Nacreous
Nov 04, 2013So do you really need to change the Host header at all? It has no effect on where the F5 sends the traffic BTW.
when HTTP_REQUEST {
if {[string tolower [HTTP::host]] starts_with "abc.com" && [string tolower[HTTP::path]] eq "/ukm"} {
This pool needs to be created with pool member 1.1.1.1:8080
pool pl_sunnyman_8080
HTTP::uri "/xyz"
}
}
when LB_SELECTED {
This will update the Host header with the IP:port of the selected server
HTTP::header replace Host "[LB::server addr]:[LB::server port]"
}
This way when you want to add more servers into your pool, the Host header will get rewritten with whatever server got chosen from the pool, but as I said, unless you have a particular reason to rewrite the Host header I wouldn't bother - it has no effect on routing.