Forum Discussion
Jean_Mamène
Cirrus
Jun 25, 2019Rewrite HTTP host based on server name loadbalanced
Hi all, My application is not compatible with the reverse proxy. I have 2 servers in my pool. I need to replace the http host with the name of the server loadbalanced. I try this iRule wh...
Dario_Garrido
Noctilucent
Jun 25, 2019Hello Jean.
I would say that "LB::server addr" is not a valid method to use in this event (HTTP_REQUEST_SEND) base on this -> https://clouddocs.f5.com/api/irules/LB__server.html
I recommend you to use "IP::server_addr" instead. I'm also including some log events to trace the iRule variables. You can remove those logs after verify that everything is working properly.
when HTTP_REQUEST_SEND {
clientside {
log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] request to [HTTP::host][HTTP::uri]"
if {[HTTP::host] equals "bi.test.com"} {
set host_header_value [class match -value [IP::server_addr] equals test-datagroup]
log local0. "[IP::client_addr]:[TCP::client_port]: Looked up [IP::server_addr], found: $host_header_value."
if {$host_header_value ne ""}{
HTTP::header replace Host $host_header_value
log local0. "[IP::client_addr]:[TCP::client_port]: Replaced Host header with $host_header_value."
}
}
}
}
REF - https://devcentral.f5.com/s/articles/rewrite-host-header-to-server-name
KR,
Dario.
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