Forum Discussion
IRULE redirection to maintenance pool based on client IP and cookie...
- Apr 12, 2017
I think this will do what you need...
when HTTP_REQUEST { if {[class match [HTTP::header "True-Client-IP"] equals MAINTENANCE-CLIENTS]} { if {[HTTP::cookie exists "MAINTENANCE"]} { switch -glob [string tolower [HTTP::uri]] { "/site1*" - "/site2*" - "/site3*" { pool MAINT-A; persist cookie } } go no further return } } switch -glob [string tolower [HTTP::uri]] { "/site1*" { pool POOL-A; persist cookie } "/site2*" { pool POOL-B ; persist cookie } "/site3*" { pool POOL-C; persist cookie } } }
I think this will do what you need...
when HTTP_REQUEST {
if {[class match [HTTP::header "True-Client-IP"] equals MAINTENANCE-CLIENTS]} {
if {[HTTP::cookie exists "MAINTENANCE"]} {
switch -glob [string tolower [HTTP::uri]] {
"/site1*" -
"/site2*" -
"/site3*" { pool MAINT-A; persist cookie }
}
go no further
return
}
}
switch -glob [string tolower [HTTP::uri]] {
"/site1*" { pool POOL-A; persist cookie }
"/site2*" { pool POOL-B ; persist cookie }
"/site3*" { pool POOL-C; persist cookie }
}
}
- Kevin_Davies_40Apr 12, 2017Nacreous
Only if the True-Client-IP equals the data class AND the cookie exists will it select the maintenance pool. Otherwise it will process the next section routing traffic as normal. If the header does not exist it will simply return "" which should not match anything in the data class.
- matt1985_299432Apr 12, 2017Nimbostratus
Thanks Kevin looks allot cleaner ;) I will give it a try...
- matt1985_299432Apr 12, 2017Nimbostratus
Hi Kevin,
That works much better certainly if I set client IP AND cookie as specified it still gets me to the maintenance pools. However not falling through to the normal pools when there is no specific cookie client IP required.. just trying to work that through
Thanks
Matt
- Kevin_Davies_40Apr 12, 2017Nacreous
Are you trying to change the pool for an established connection? The F5 only load balances at the start of the connection setup. You cannot change servers mid TCP connection unless you apply a oneconnect profile to the virtual server (properties, near the bottom). This then allows you to load balance per HTTP request.
- matt1985_299432Apr 13, 2017Nimbostratus
HI Kevin,
Thanks for coming back to me. No I am not trying to change the pool for an active connection. Essentially we are using a separate process with the application and F5 monitors to disable a server in one pool and enable in another pool when we set maintenance. This all works fine.
So when we put a server in maintenance at that point we want some of our testers to hit the maintenance pool based on trueclient ip AND them setting a cookie..
This does actually work all fine its just my original irule was not very efficient / graceful. You have given me something good to work with here..
Thanks
Matt
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