Created
November 1, 2012 07:57
-
-
Save Chairo/3992376 to your computer and use it in GitHub Desktop.
default.vcl for version 2.x
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
backend au92 { | |
.host = "www.au92.com"; | |
.port = "80"; | |
.connect_timeout = 600s; | |
.first_byte_timeout = 600s; | |
.between_bytes_timeout = 600s; | |
.max_connections = 800; | |
} | |
acl purge { | |
"localhost"; | |
"127.0.0.1"; | |
"192.168.1.0"/24; | |
"60.247.127.0"/24; | |
} | |
sub vcl_recv { | |
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 ~ purge) { | |
error 405 "Not allowed."; | |
} | |
return (lookup); | |
} | |
if (req.http.host ~ "^(www.)?au92.com") { | |
set req.backend = au92; | |
} else { | |
error 404 "test Cache Server"; | |
} | |
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.http.Expect) { | |
return (pipe); | |
} | |
if (req.http.Authenticate || req.http.Cookie || req.url ~ "\.(php|cgi)($|\?)") { | |
return (pass); | |
} | |
if (req.request == "GET" && req.url ~ "\.(txt|js|jpg|gif|png|bmp|css|html|htm|ico)$") { | |
return (lookup); | |
} | |
return (lookup); | |
} | |
sub vcl_hit { | |
if (req.request == "PURGE") { | |
set obj.ttl = 0s; | |
error 200 "Purged."; | |
} | |
return (deliver); | |
} | |
sub vcl_miss { | |
if (req.request == "PURGE") { | |
error 404 "Not in cache."; | |
} | |
set bereq.url = regsub(req.url, "\?.*", ""); | |
return (fetch); | |
} | |
sub vcl_fetch { | |
if (!beresp.cacheable || beresp.http.Set-Cookie) | |
{ | |
return (pass); | |
} | |
if (req.request == "GET" && req.url ~ "\.(txt|js|jpg|gif|png|bmp|css|html|htm|ico)$") { | |
set beresp.ttl = 30d; | |
} | |
else { | |
set beresp.ttl = 3d; | |
} | |
return (deliver); | |
} | |
sub vcl_hash { | |
set req.hash += req.url; | |
if (req.http.host) { | |
set req.hash += req.http.host; | |
} else { | |
set req.hash += server.ip; | |
} | |
return (hash); | |
} | |
sub vcl_pipe { | |
return (pipe); | |
} | |
sub vcl_pass { | |
return (pass); | |
} | |
sub vcl_deliver { | |
remove resp.http.X-Varnish; | |
remove resp.http.Via; | |
return (deliver); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment