Forum Discussion
Direct HTTP request from an IP to specific pool members
We have an iRule works OK as below. HTTP requests are directed to coresponding pools respectively according to URI.
Rule_1:
when HTTP_REQUEST {
switch -glob [HTTP::uri] {
"/video/*" { pool VIDEO }
"/audio/*" {pool AUDIO}
"/text/*" {pool TEXT}
default {pool default_pool}
}
}
Now we want to divert all HTTP requests coming from IP 1.2.3.4 to the first member of each pool.
I add a new rule Rule_2 above Rule_1.
Rule_2:
when HTTP_REQUEST {
if { [HTTP::header "True-Client-IP"] equals "1.2.3.4"} {
log local0. " Requests from 1.2.3.4"
switch -glob [HTTP::uri] {
"/video/*" { pool VIDEO member video_a}
"/audio/*" {pool AUDIO member audio_a}
"/text/*" {pool TEXT member text_a}
default {pool default_pool member default_a}
}
}
}
It doesn't work. I can see the log " Requests from 1.2.3.4" though, but HTTP request can still land on other pool members.
Any hits or advise are much appreciated.
- Mohamed_Lrhazi
Altocumulus
Not how persistence works with an iRule "pool" command... but am wondering if it is not sending a request to a different pool member because if persistence. - nathe
Cirrocumulus
tqupriority 100 when HTTP_REQUEST { switch -glob [HTTP::uri] { "/video/*" { pool VIDEO } "/audio/*" {pool AUDIO} "/text/*" {pool TEXT} default {pool default_pool} } } priority 10 when HTTP_REQUEST { if { [HTTP::header "True-Client-IP"] equals "1.2.3.4"} { log local0. " Requests from 1.2.3.4" switch -glob [HTTP::uri] { "/video/*" { pool VIDEO member video_a} "/audio/*" {pool AUDIO member audio_a} "/text/*" {pool TEXT member text_a} default {pool default_pool member default_a} } } }
- nathe
Cirrocumulus
tquwhen HTTP_REQUEST { if { [HTTP::header "True-Client-IP"] equals "1.2.3.4"} { log local0. "Requests from 1.2.3.4" switch -glob [HTTP::uri] { "/video/*" { pool VIDEO member video_a} "/audio/*" {pool AUDIO member audio_a} "/text/*" {pool TEXT member text_a} default {pool default_pool member default_a} } } else { switch -glob [HTTP::uri] { "/video/*" { pool VIDEO } "/audio/*" {pool AUDIO} "/text/*" {pool TEXT} default {pool default_pool} } } }
You can also choose a specific pool member using the pool command: pool HTTP_pool member 10.10.10.1 80
- nathe
Cirrocumulus
tquwhen HTTP_REQUEST { if { [HTTP::header "True-Client-IP"] equals "1.2.3.4"} { log local0. "Requests from 1.2.3.4" switch -glob [HTTP::uri] { "/video/*" { pool VIDEO member video_a} "/audio/*" {pool AUDIO member audio_a} "/text/*" {pool TEXT member text_a} default {pool default_pool member default_a} } } else { switch -glob [HTTP::uri] { "/video/*" { pool VIDEO } "/audio/*" {pool AUDIO} "/text/*" {pool TEXT} default {pool default_pool} } } }
- tqu_93931
Nimbostratus
Thank you for your responses. - Mohamed_Lrhazi
Altocumulus
I don't know about who wins, the pool command in an iRule or the persistence table. You could ask Support. - tqu_93931
Nimbostratus
@Nathan, thank you so much. It looks like your proposed script works! - tqu_93931
Nimbostratus
Hi guys, sorry. It still doesn't work, when I test it massively with automated testing. :( - What_Lies_Bene1
Cirrostratus
It might be wise to enable OneConnect for the Virtual Server and retest, this should stop persistence and the iRule conflicting. - tqu_93931
Nimbostratus
OneConnect Profile is enabled. but still not working.
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