Forum Discussion
milanv_137346
Nimbostratus
Nov 20, 2013Set Host header
Hi,
I'm a newbie to this. Can someone help me correct the iRule below?
We need the first value in the X-Forwarded-Host to be assigned to the Host header
regards,
Milan
when HTTP_REQUEST {
i...
Kevin_Stewart
Employee
Nov 20, 2013Try this:
when HTTP_REQUEST {
if { [HTTP::header exists X-Forwarded-Host] } {
HTTP::header replace X-Forwarded-Host [string trim [lindex [split [HTTP::header X-Forwarded-Host] ","] 0]]
}
}
If the header exists, there's a pretty good bet that it'll have at last one value. If the header has two values delimited with a comma, the above will take the first one. If the header only contains one value, then the split function will produce a list of one, which will still be at the 0 index.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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