Skip to content

Instantly share code, notes, and snippets.

@hSATAC
Created August 22, 2014 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hSATAC/d72f6d8eb7e426dc2ced to your computer and use it in GitHub Desktop.
Save hSATAC/d72f6d8eb7e426dc2ced to your computer and use it in GitHub Desktop.
sub vcl_recv {
# .....
# cookie sanitization
if (req.http.Cookie) {
set req.http.Cookie = ";"+req.http.Cookie;
set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
set req.http.Cookie = regsuball(req.http.Cookie, ";(locale)=", "; \1=");
set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");
if (req.http.Cookie == "") {
unset req.http.Cookie;
}
}
# .....
}
sub vcl_hash {
hash_data(req.url);
if (req.http.host) {
hash_data(req.http.host);
} else {
hash_data(server.ip);
}
# hash cookies for requests that have them
if (req.http.Cookie) {
hash_data(req.http.Cookie);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment