Forum Discussion
iRule, Traffic Policy or Re-Write Policy
Hi,
I have created an iRule that maps source addresses to a particular pool
when CLIENT_ACCEPTED {
if {[class match [IP::client_addr] equals clients1] } {
pool POOL_1
} elseif {[class match [IP::client_addr] equals clients2] } {
pool POOL_2
} elseif {[class match [IP::client_addr] equals clients3] } {
pool POOL_3
} elseif {[class match [IP::client_addr] equals clients4] } {
pool POOL_4
} elseif {[class match [IP::client_addr] equals clients5] } {
pool POOL_5
}
else {
pool POOL_6
}
}
I have a re-write policy that changes the uri
https://example.com to https://examples.com/test
When the connection completes to the backend servers, they respond with their hostname in the browser.
I want to keep https://example.com on the client side but I'm not sure how to achieve this. I thought I could do a response within my re-write policy but this fails.
I then looked at traffic policies but already have an ASM policy attached
Should I try and achieve everything under one irule (if so how, might I do this)
- It replaces the original uri with a new uri (going to the server)
- Have my current source to pool mapping
- Replace the server hostname with the original uri https://example.com
Thanks for any pointers
1 Reply
- Injeyan_Kostas
Nacreous
Hi sjy2025
the best solution would be to config application use relative paths
for now you can try this irule, you will need to apply stream profile also
when CLIENT_ACCEPTED { STREAM::disable if {[class match [IP::client_addr] equals clients1] } { pool POOL_1 } elseif {[class match [IP::client_addr] equals clients2] } { pool POOL_2 } elseif {[class match [IP::client_addr] equals clients3] } { pool POOL_3 } elseif {[class match [IP::client_addr] equals clients4] } { pool POOL_4 } elseif {[class match [IP::client_addr] equals clients5] } { pool POOL_5 } else { pool POOL_6 } } when HTTP_REQUEST { STREAM::disable HTTP::header remove "Accept-Encoding" set original_uri [HTTP::uri] HTTP::uri "/test${original_uri}" } when HTTP_RESPONSE { STREAM::disable if {[HTTP::header exists "Location"]} { set loc [HTTP::header "Location"] if {[string match "https://examples.com*" $loc]} { HTTP::header replace "Location" [string map {"https://examples.com" "https://example.com"} $loc] } } if {[HTTP::header "Content-Type"] contains "text"} { STREAM::expression {@https://examples.com@https://example.com@} STREAM::enable } }
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