Forum Discussion
Need to change HTTP header depending on pool member selected
Based on a pool member selected we need to change the Host name in HTTP::header before the request is sent to the target server. I have tried to do this with the following iRule but there is an error being thrown when the HTTP::header replace is being processed.
when SERVER_CONNECTED {
log local0. "Connected to [IP::server_addr]"
switch [IP::server_addr] {
"1.2.3.4" -
"1.2.3.5" {
log local0. "Found IP in the legacy list. Will not modify HTTP header"
}
"2.3.4.5" {
log local0. "Found IP in the new list. Modify HTTP header"
HTTP::header replace Host "newhost.com"
}
}
}
This is failing with operation not support:
Sep 4 15:11:10 local/tmm2 err tmm2[7000]: 01220001:3: TCL error: tcv - Operation not supported (line 1) invoked from within "HTTP::header replace Host "newhost.com" " ("2.3.4.5" arm line 3) invoked from within "switch [IP::server_addr] { "1.2.3.4" - "1.2.3.5" { log local0. "Found IP in the legacy list. Will not modify ..."
I tried this with "when HTTP_REQUEST" as well, but since there is no pool member selected yet, that wasn't working either. In this configuration, there are 3 members in the pool:
1.2.3.4
1.2.3.5
and
2.3.4.5
Any suggestions on if this is possible?
- Kevin_StewartEmployeeYou should use the HTTP_REQUEST_SEND event:
when HTTP_REQUEST_SEND { log local0. "Connected to [IP::server_addr]" switch [IP::server_addr] { "10.70.0.1" { log local0. "Not changing the host header" } "10.70.0.2" { log local0. "changing the host header" clientside { HTTP::header replace Host "newhost.com" } } } }
- Tim_Vaudt_11296NimbostratusMuch thanks Kevin. Working great.
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