Varnish purge behind nginX proxy

Bertrand Caplet bertrand.caplet at chunkz.net
Wed Apr 15 00:35:39 CEST 2015


> Can you post your VCL? There's a vmod to pass True-Client-Ip through.

Here you go:

vcl 4.0;

# Default backend definition. Set this to point to your content server.
backend default {
    .host = "127.0.0.1";
    .port = "8082";
}
 acl purge {
"127.0.0.1";
}

# Drop any cookies sent to Wordpress.
sub vcl_recv {
  # Set the X-Forwarded-For header so the backend can see the original
  # IP address. If one is already set by an upstream proxy, we'll just
re-use that.
    if (req.http.X-Forwarded-For) { # set or append the client.ip to
X-Forwarded-For header
      set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " +
client.ip;
    } else {
      set req.http.X-Forwarded-For = client.ip;
    }

 if (req.url ~ "wp-admin|wp-login") {

return (pass);

}

set req.http.cookie = regsuball(req.http.cookie,
"wp-settings-\d+=[^;]+(; )?", "");

set req.http.cookie = regsuball(req.http.cookie,
"wp-settings-time-\d+=[^;]+(; )?", "");

set req.http.cookie = regsuball(req.http.cookie,
"wordpress_test_cookie=[^;]+(; )?", "");
set req.http.cookie = regsuball(req.http.cookie, "quick_chat[^;]", "");
set req.http.Cookie = regsuball(req.http.Cookie, "(^|(?<=; ))
*__quick_chat_alias.=[^;]+;? *", "\1");
if (req.http.cookie == "") {

unset req.http.cookie;
}

if (req.method == "PURGE") {

        if (!client.ip ~ purge) {

        return (synth(405,"Not allowed."));

        }
        return (purge);
}
}


I already tried vmod_std with this string :
if (std.ip(req.http.X-forwarded-for, "0.0.0.0") !~ purge)

but I got the following error :
Message from VCC-compiler:
Symbol not found: 'std.ip' (expected type BOOL)

Do you have a clue ?


-- 
CHUNKZ.NET - script kiddie and computer technician
Bertrand Caplet, Flers (FR)
Feel free to send encrypted/signed messages
Key ID: 37F70C30
GPG FP: 134A 4027 518B 5F4D D409 558D BA9B 7BF0 37F7 0C30



More information about the varnish-misc mailing list