Created
April 16, 2010 06:01
-
-
Save p/368082 to your computer and use it in GitHub Desktop.
This file contains 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. | |
# backend definition | |
backend default { | |
.host = "tracker.phpbb.com"; | |
.port = "80"; | |
} | |
# transformations on client requests | |
sub vcl_recv { | |
# set host to backend host, otherwise client host is passed through | |
set req.http.host = "tracker.phpbb.com"; | |
# /s/ and /images/ are static file urls. | |
# header-separator and dropdowns are images which are not session-dependent. | |
# clear cookies from client requests, which will allow such requests to be cached | |
# http://varnish-cache.org/wiki/VCLExampleCacheCookies | |
if (req.url ~ "^/(s|images)/" || req.url ~ "^/rest/api/1.0/(header-separator|dropdowns)($|\?)") { | |
unset req.http.cookie; | |
} | |
# clean out requests sent via curls -X mode and LWP | |
# http://varnish-cache.org/wiki/VCLExampleNormalizingReqUrl | |
if (req.url ~ "^http://") { | |
set req.url = regsub(req.url, "http://[^/]*", ""); | |
} | |
# normalize accept-encoding header | |
# http://varnish-cache.org/wiki/FAQ/Compression | |
if (req.http.Accept-Encoding) { | |
if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$") { | |
# 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 { | |
# unkown algorithm | |
remove req.http.Accept-Encoding; | |
} | |
} | |
} | |
# transformations on backend responses | |
sub vcl_fetch { | |
# /s/ and /images/ are static file urls. | |
# header-separator and dropdowns are images which are not session-dependent. | |
# if response contains any cookies, remove cookies before storing response in cache | |
# and returning it to client. | |
# note: incoming cookies are removed in vcl_recv block | |
if (req.url ~ "^/(s|images)/" || req.url ~ "^/rest/api/1.0/(header-separator|dropdowns)($|\?)") { | |
unset beresp.http.set-cookie; | |
} | |
# offsite use only - rewrite location header in redirects | |
# http://varnish-cache.org/wiki/VCLExampleRemovingSomeCookies | |
if (beresp.http.location) { | |
set beresp.http.location = regsub(beresp.http.location, "^http://tracker.phpbb.com/", "/"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment