# This is a basic VCL configuration file for varnish. See the vcl(7)# man page for details on VCL syntax and semantics.## Default backend definition. Set this to point to your content# server.#
backend default {
.host = "127.0.0.1";
.port = "80";
}## Below is a commented-out copy of the default VCL logic. If you# redefine any of these subroutines, the built-in logic will be# appended to your code.#
sub vcl_recv {set req.backend = default;
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;
}}####################### Remove cookies #######################set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(__[a-z]+|has_js)=[^;]*", "");
set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(s_cc|s_sq)=[^;]*", "");
set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(base_domain_|fbsetting_)[^;]*", "");
set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(_gscu_|_gscs_|_gscbrs_|zinch_flag_like|zt|paq_cookietime)[^;]*", "");
set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");
if(req.http.Cookie ~ "^\s*$"){
remove req.http.Cookie;
}# Cache these file typesif(req.url ~ "\.(jpg|png|css|js|ico|gz|tgz|bz2|tbz|gif)$"&& req.url !~ "\?"){
remove req.http.cookie;
}# Properly handle different encoding typesif(req.http.Accept-Encoding){if(req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|csv|pdf)$"){# No point in compressing these
remove req.http.Accept-Encoding;
} elsif (req.http.Accept-Encoding ~ "gzip"){set req.http.Accept-Encoding = "gzip";
} elsif (req.http.Accept-Encoding ~ "deflate"){set req.http.Accept-Encoding = "deflate";
}else{# unknown algorithm
remove req.http.Accept-Encoding;
}}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);
}if(req.http.Authorization || req.http.Cookie){/* Not cacheable by default */return(pass);
}return(lookup);
}
sub vcl_fetch {if(req.url ~ "\.(jpg|png|css|js|ico|gz|tgz|bz2|tbz|gif)$"&& req.url !~ "\?"){unset beresp.http.set-cookie;
}}