Forum Discussion
Redirect URIs in datagroup to dedicated node
southern_nordic For various reasons you should try not to send traffic to a specific node and instead you should create a pool for this single node and reference that pool instead. I believe the following will correct your error as well as send traffic to a pool with just the single node in it rather than referencing the node by itself. This iRule also assumes you have a default pool configured on the VS and will send traffic to that pool if it doesn't match the data-group list.
when CLIENT_ACCEPTED priority 500 {
set DEFAULT_POOL [LB::server pool]
}
when HTTP_REQUEST priority 500 {
# Get the request URI
set request_uri [HTTP::uri]
# Check if the request URI matches any entry in the data group
if { [class match -- ${request_uri} == ACL_Intranett-webforms] } {
# Set the persistence cookie name
set persistence_cookie_name "stick_cookie_name"
# Check if the persistence cookie exists
set cookie_value [HTTP::cookie ${persistence_cookie_name}]
if { ${cookie_value} == "" } {
# If the cookie doesn't exist, create and set the cookie
set cookie_value [IP::client_addr]
HTTP::cookie insert ${persistence_cookie_name} ${cookie_value}
}
# Set the persistence based on the cookie
persist uie cookie ${persistence_cookie_name}
pool POOL_ACL_Intranett_Webforms
} else {
pool ${DEFAULT_POOL}
}
}
Thanks Paulios, I should have mentioned we have a default pool and I had intended to create a seperate pool for this traffic.
I applied your irule , however I received the following error
01070151:3: Rule 13: error: ["== is unexpected; it should be one of 'contains ends_with equals starts_with'"][class match -- ${request_uri} == ACL_Intranett-webforms]
- PauliusOct 06, 2023MVP
southern_nordic It looks like class match doesn't like using "==" and instead wants "eq" which I have corrected below.
when CLIENT_ACCEPTED priority 500 { set DEFAULT_POOL [LB::server pool] } when HTTP_REQUEST priority 500 { # Get the request URI set request_uri [HTTP::uri] # Check if the request URI matches any entry in the data group if { [class match -- ${request_uri} eq ACL_Intranett-webforms] } { # Set the persistence cookie name set persistence_cookie_name "stick_cookie_name" # Check if the persistence cookie exists set cookie_value [HTTP::cookie ${persistence_cookie_name}] if { ${cookie_value} == "" } { # If the cookie doesn't exist, create and set the cookie set cookie_value [IP::client_addr] HTTP::cookie insert ${persistence_cookie_name} ${cookie_value} } # Set the persistence based on the cookie persist uie cookie ${persistence_cookie_name} pool POOL_ACL_Intranett_Webforms } else { pool ${DEFAULT_POOL} } }
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