Created
February 26, 2018 18:13
-
-
Save cosimo/a88fd27eb62b86c607f0f0cb7c66aed9 to your computer and use it in GitHub Desktop.
Varnish: clean up 127.0.0.1 from X-Forwarded-For header in VCL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Varnish appends ${localhost} (= 127.0.0.1) to the XFF header | |
# automatically and transparently *before* calling vcl_recv(). | |
# | |
# Not a problem for the Rest backend, but in the interest of | |
# trying to be as transparent as possible, we have the option | |
# to clean it out. | |
# | |
sub clean_x_forwarded_for { | |
if (req.http.X-Forwarded-For != "") { | |
set req.http.X-Forwarded-For = regsub(req.http.X-Forwarded-For, | |
"^(.+)\s*,\s*127\.0\.0\.1$", "\1"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment