Forum Discussion
iRule, Traffic Policy or Re-Write Policy
- 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 } }
There is a redirect
The solution is partially working on a single test network.
Client connects to uri > f5 has a re-write profile > that changes the uri to be the name of the back end server (Keycloak)
https://hostnameA.test.com:666
In the browser of the client I get the https://hostnameA.test.com:666 which exposes the server name
I'd like the client to not see this.
I have this on multiple test environments, each with their own dedicated server
....
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 try
when 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
}
}
- sjy2025Oct 01, 2025
Nimbostratus
This has solved my issue, specifically the HTTP_REQUEST section. The response has been dealt with by another means. Thanks for your help
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