Forum Discussion
Bubbagump_12531
Nimbostratus
Oct 30, 2013Prevent X-Forwarded-For spoofing
We insert an X-Forwarded-For header to pass back to our web servers. One application we have looks to this header to allow or deny certain servers access to us. However, we want to prevent spoofing t...
Bubbagump_12531
Nimbostratus
Oct 30, 2013Bah, I completely missed that. Yes it does work. Thanks so much. In the mean time I was mucking around with -nocase, but that is certainly a much more elegant solution.
However, is this not inefficient? It appears to remove the headers inserted by the HTTP profile too and not just outside headers. So perhaps an if exists, replace, else, insert and completely forgo the insert via the HTTP policy? Would this work? (or some permutation as I am by no means a TCL guy)
when HTTP_REQUEST {
foreach x [HTTP::header names] {
if { [string tolower $x] equals "x-forwarded-for" exists}
then
if { [string tolower $x] equals "x-forwarded-for" } {
HTTP::header remove $x
HTTP::header replace X-FORWARDED-FOR [IP::client_addr]
}
else
{HTTP::header insert X-FORWARDED-FOR [IP::client_addr]}
}
}
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