Created
August 10, 2013 15:16
-
-
Save sondr3/6200800 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 = "localhost"; | |
.port = "8080"; | |
} | |
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; | |
} | |
} | |
if (req.request == "PURGE") { | |
if ( client.ip != "212.71.250.152") { | |
error 405 "Not allowed."; | |
} | |
return (lookup); | |
} | |
if (req.request != "GET" && | |
req.request != "HEAD" && | |
req.request != "PUT" && | |
req.request != "POST" && | |
req.request != "TRACE" && | |
req.request != "OPTIONS" && | |
req.request != "DELETE") { | |
return (pipe); | |
} | |
if (req.request != "GET" && req.request != "HEAD") { | |
return (pass); | |
} | |
if (!(req.url ~ "wp-(login|admin)") && | |
!(req.url ~ "&preview=true" ) ) { | |
unset req.http.cookie; | |
} | |
if (req.http.Authorization || req.http.Cookie) { | |
return (pass); | |
} | |
return (lookup); | |
} | |
sub vcl_hit { | |
if (req.request == "PURGE") { | |
purge; | |
error 200 "Purged."; | |
} | |
return (deliver); | |
} | |
sub vcl_miss { | |
if (req.request == "PURGE") { | |
purge; | |
error 200 "Purged."; | |
} | |
return (fetch); | |
} | |
sub vcl_fetch { | |
if (!(req.url ~ "wp-(login|admin)")) { | |
unset beresp.http.set-cookie; | |
set beresp.ttl = 96h; | |
} | |
if (beresp.ttl <= 0s || | |
beresp.http.Set-Cookie || | |
beresp.http.Vary == "*") { | |
set beresp.ttl = 120 s; | |
return (hit_for_pass); | |
} | |
return (deliver); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment