How to switch between the pools based on the listening port using irule
- Whenever HTTP_Request hits with listening port 8080, it will switch to Poola and whenever HTTP_Request hits with listening port 1099, it shoukd go to pool : Poolb
Thanks and Regards Parveez
A simple example:
when CLIENT_ACCEPTED {
switch [TCP::local_port] {
"8080" { pool Poola }
"1099" { pool Poolb }
}
}
You could also dump these into a string-based data group. Example:
8080 := Poola
1099 := Poolb
And use a more dynamic version of the iRule:
when CLIENT_ACCEPTED {
if { [class match [TCP::local_port] equals my_port_dg] } {
pool [class match -value [TCP::local_port] equals my_port_dg]
}
}
ok Kevin thanks, so will try both the ways and let you know.
And also Kevin:
By applying the below Irule, also wanted to edit/add this irule saying to redirect it to https when the traffic hit to http.
when CLIENT_ACCEPTED { switch [TCP::local_port] { “8080” { pool Poola } “1099” { pool Poolb } } }
Thanks and Regards Parveez
Switch to this then:
when HTTP_REQUEST {
switch [TCP::local_port] {
"8080" { pool Poola }
"1099" { pool Poolb }
"80" { HTTP::redirect "https://[HTTP::host][HTTP::uri]"
}
}