backend default {
.host = "10.32.26.31";
.port = "";
}
sub vcl_recv {
if (req.url ~ "\&gv=.*\&av=.*\&uid=.*\&proid=.*\&os=.*\&df=.*\&vt=.*\&screen=.*\&publishid=\d+") {
set req.url = regsub(req.url, "\&gv=.*\&av=.*\&uid=.*\&proid=.*\&os=.*\&df=.*\&vt=.*\&screen=.*\&publishid=\d+", "");
}
if (req.restarts == ) {
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;
}
}
if (req.request != "GET" &&
req.request != "HEAD" &&
req.request != "PUT" &&
req.request != "POST" &&
req.request != "TRACE" &&
req.request != "OPTIONS" &&
req.request != "DELETE") {
/* Non-RFC2616 or CONNECT which is weird. */
return (pipe);
}
if (req.request != "GET" && req.request != "HEAD") {
/* We only deal with GET and HEAD by default */
return (pass);
}
return (lookup);
}
sub vcl_pipe {
return (pipe);
}
sub vcl_pass {
return (pass);
}
sub vcl_hit {
return (deliver);
}
sub vcl_miss {
if (req.request == "PURGE") {
error "Not in cache";
}
return (fetch);
}
sub vcl_fetch {
if (req.request == "GET" && req.url ~ "/qqcallback\.(php).+") {
set beresp.ttl = 0s;
}
if (req.request == "GET" && req.url ~ "/getspecial\.(php).+") {
set beresp.ttl = 0s;
}
if (req.request == "GET" && req.url ~ "\.(php).+") {
set beresp.ttl = 3m;
}
if ( req.url ~ "\.(gif|jpg|png|jpeg|swf|css|js)$" ) {
set beresp.ttl = 10m;
}
if (beresp.status == ) {
set beresp.ttl = 3s;
}
}
参考 http://blog.csdn.net/keda8997110/article/details/8777153