Forum Discussion
milanv_137346
Nov 15, 2013Nimbostratus
X-Forwarded-Host
I wish to set the Host Header to the first value in the X-Forwarded-Host header.
Any suggestions on how to best achieve this.
We wrote the code below but it did not work. Can you please assist i...
Kevin_Stewart
Nov 15, 2013Employee
Try this:
when HTTP_REQUEST {
if { [HTTP::header exists X-Forwarded-Host] } {
HTTP::header replace Host [string trim [lindex [split [HTTP::header X-Forwarded-Host] ","] 0]]
}
}
This of course assumes that X-Forwarded-Host contains 2 host names separated by a comma, versus two separate X-Forwarded-Host headers (which might also be possible).
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