Forum Discussion
sjy2025
Nimbostratus
Jul 22, 2025iRule, 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...
- Sep 24, 2025
you may see https://hostnameA.test.com:666 in the browser for many reasons
thats why I am asking if there is a redirect response (301 or 302) or there is something else
anyway give this a trywhen HTTP_REQUEST { STREAM::disable HTTP::header remove "Accept-Encoding" if {[IP::addr [IP::client_addr] equals 192.168.1.1] } { pool POOL_A set selected_hostname "hostnameA.test.com" HTTP::header replace Host $selected_hostname } elseif {[IP::addr [IP::client_addr] equals 192.168.2.1] } { pool POOL_B set selected_hostname "hostnameB.test.com" HTTP::header replace Host $selected_hostname } elseif {[IP::addr [IP::client_addr] equals 192.168.3.1] } { pool POOL_C set selected_hostname "hostnameC.test.com" HTTP::header replace Host $selected_hostname } } when HTTP_RESPONSE { if {[HTTP::header exists "Location"] && [info exists selected_hostname]} { set loc [HTTP::header "Location"] if {[string match "https://$selected_hostname:666*" $loc]} { HTTP::header replace "Location" [string map "https://$selected_hostname:666 https://example.com" $loc] } } if {[HTTP::header "Content-Type"] contains "text" && [info exists selected_hostname]} { STREAM::expression "@https://$selected_hostname@https://example.com@" STREAM::enable } }
Injeyan_Kostas
Nacreous
Jul 22, 2025Hi 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
DevCentral Quicklinks
* 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
Discover DevCentral Connects