Forum Discussion
Manuel_60430
Nimbostratus
Mar 25, 2014TCL error message with X-Forwarded-For iRule
We are using the X-Forwarded-For http header field on the BigIP LTM to server our webshop application with client IP addresses (to determinde country hawk and so on). Our web application can only wor...
Kevin_Stewart
Employee
Apr 01, 2014It could be that you're trying to evaluate/insert/replace headers in the same context as a redirect. It may make more sense to combine the iRule cohesively:
when HTTP_REQUEST {
'root domain redirect'
if { [HTTP::host] == "mydomain.com" } {
HTTP::respond 301 Location http://www.mydomain.com[HTTP::uri]
} elseif { [class match [string tolower [HTTP::uri]] equals REDIRECTS_301_SCO ] } {
HTTP::respond 301 Location [class lookup [string tolower [HTTP::uri]] REDIRECTS_301_SCO ]
} else {
if { [HTTP::header exists True-Client-IP] } {
HTTP::header replace X-Forwarded-For [HTTP::header True-Client-IP]
} else {
HTTP::header replace X-Forwarded-For [IP::client_addr]
}
}
}
What F5 version is this? I'm not 100% sure of the second iRule as the HTTP::request command, at least not on a v10 or v11 system, would return a value like "http://asia.mydomain.com/taiwan". Are you certain this iRule is actually working?
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