Logging the client IP with Nginx/Varnish/Apache
Rowan @ Jetboy
rowan at jetboy.co.uk
Tue Oct 23 13:03:00 CEST 2012
David,
I'm a little confused. As I understand it, the default Varnish vcl_recv
behaviour will be appended to my custom rules. In Varnish 3, this includes:
# sub vcl_recv {
# if (req.restarts == 0) {
# if (req.http.x-forwarded-for) {
# set req.http.X-Forwarded-For =
# req.http.X-Forwarded-For + ", " + client.ip;
# } else {
# set req.http.X-Forwarded-For = client.ip;
# }
# }
which seems to be pretty much the same as you've posted. Can I assume that
this already being parsed (as my custom vcl_recv isn't terminated), and not
doing what I need?
<snip>
choose your own adventure.
in vcl_recv:
if (req.http.x-forwarded-for) {
# remove req.http.X-Forwarded-For;
# set req.http.X-Forwarded-For = client.ip;
#retain x-forwarded-for data and append
set req.http.X-Forwarded-For = req.http.X-Forwarded-For ","
client.ip;
} else {
set req.http.X-Forwarded-For = client.ip;
}
(noting that I use 2.1...)
--
david raistrick http://www.netmeister.org/news/learn2quote.html
drais at icantclick.org ascii ribbon campaign - stop html mail
http://www.asciiribbon.org/
More information about the varnish-misc
mailing list