Forum Discussion
Irule redirection based on URL
Hi, I need to create a VIP, an redirect the traffic to different Pool depending of the URL requested. I have created this Irule: when HTTP_REQUEST {
if { [HTTP::host] eq "URL_1" } {
pool POOL_1
}
elseif { [HTTP::host] eq "URL_2" } {
pool POOL_2
}
elseif { [HTTP::host] eq "URL_3" } {
pool POOL_3
}
elseif { [HTTP::host] eq "URL_4"} {
pool POOL_4
}
}
URL_1 [...] and URL_4 have the same VIP IP. Each POOL have been created via GUI.
Usually, each time i create a VIP, i need to associate it to a POOL. But for my case, i don't know how to implement it, becasue i have 4 POOL.
thanks for your help.
Best regards
Hi Mbarreau,
I'd prefer the
command to parse the requestedswitch
value forHTTP::host
selection.pool
when HTTP_REQUEST { switch -exact -- [string tolower [HTTP::host]] { "site1.domain.de" { pool pool_1 } "site2.domain.de" { pool pool_2 } "site3.domain.de" { pool pool_3 } "site4.domain.de" { pool pool_4 } } }
Note: The the example above uses a
command to ignore the case during evaluation. It helps to make the pool selection more robust...[string tolower [HTTP::host]]
Cheers, Kai
- Mat78_387100
Nimbostratus
I modify the irule to get some logs. Now, the Irule looks like that: when CLIENT_ACCEPTED { set client [IP::client_addr] log local0. "Client: $client has established a connection"
when SERVER_CONNECTED { set pool_name [LB::server pool] log local0. "Client Source IP: [IP::client_addr]:[TCP::client_port] <--> POOL : $pool_name <--> ACTUALNODE <--> [IP::server_addr]:[TCP::server_port]" }
It still not working, and on the log, i didn't see the URL requested: Apr 11 16:26:12 BIG-IP-LTM info tmm1[10587]: Rule /Common/Irule_TEST : Client: X.X.X.X has established a connection Apr 11 16:26:12 BIG-IP-LTM info tmm1[10587]: Rule /Common/Irule_TEST : Client: X.X.X.X has established a connection Apr 11 16:26:12 BIG-IP-LTM info tmm1[10587]: Rule /Common/Irule_TEST : Client Source IP: X.X.X.X:31506 is requesting URL: Apr 11 16:26:12 BIG-IP-LTM info tmm1[10587]: Rule /Common/Irule_TEST : Client: X.X.X.X has established a connection Apr 11 16:26:12 BIG-IP-LTM info tmm1[10587]: Rule /Common/Irule_TEST : Client Source IP: X.X.X.X:28300 is requesting URL:
For sure, something is missing on my configuration. On the Virtual server, you just have to add the irule, no POOL ?
regards
Recent Discussions
Related Content
* 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