View pagespeed-requirement.vcl
# Note: You will want to add the snippet: `include "pagespeed-requirement.vcl";` above your `vcl_recv` in the default.vcl file. | |
sub vcl_recv { | |
call pagespeed_capability_detection; | |
} | |
# Function derived from requirements here https://modpagespeed.com/doc/downstream-caching#ps-capabilitylist | |
# Additional detection logic for crawlers, tablet and mobile devices. | |
sub pagespeed_capability_detection { | |
if (req.http.User-Agent ~ "(?i)Chrome/[3][2-9]+\.|Chrome/[4-9][0-9]+\.|Chrome/[0-9]{3,}\.") { |
View ForceHTTPSVarnish4.vcl
sub vcl_recv { | |
if (req.http.X-Forwarded-Proto !~ "https") { | |
return (synth(850, "Moved Permanently")); | |
} | |
} | |
sub vcl_synth { | |
if(resp.status == 850) { | |
set resp.http.Location = "https://" + req.http.host + req.url; | |
set resp.status = 301; |
View basicAuthVCL4.vcl
sub vcl_recv { | |
if (! req.http.Authorization ~ "Basic dXNlcm5hbWU6cGFzc3dvcmQ=") { | |
# This is checking for base64 encoded username:password combination | |
return(synth(401, "Authentication required")); | |
} | |
unset req.http.Authorization; | |
} |
View templarbit-agent.json
{ | |
"property-id": "<insert perperty ID>", | |
"secret-key": "<insert secret key>", | |
"monitor-only": true | |
} |
View wordpressConfig.vcl
# Ref: https://www.varnish-software.com/blog/step-step-speed-wordpress-varnish-software | |
# This is an example VCL file for Varnish. | |
# | |
# It does not do anything by default, delegating control to the | |
# builtin VCL. The builtin VCL is called when there is no explicit | |
# return statement. | |
# | |
# See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/ | |
# and http://varnish-cache.org/trac/wiki/VCLExamples for more examples. |
View CustomMaintenancePage.vcl
import std; | |
acl whitelist { | |
"123.123.123.123"; | |
"216.3.128.12"; | |
} | |
sub vcl_recv { | |
# If not a whitelisted IP, then display maintenance page. Requires std library. | |
if(std.ip(regsub(req.http.X-Forwarded-For, "[, ].*$", ""), client.ip) !~ whitelist) { |
View shieldsquare.json
{ | |
"key":"<ShieldsquareAPIKey>", | |
"enabled":true, | |
"deployment_number":"<IntegrationDeploymentNumber>", | |
"support_email":"<YourSupportEmail>" | |
} | |
View kraken.json
{ | |
"api_key": "<Kraken API Key>", | |
"api_key_secret": "<Kraken API Secret", | |
"cache_version": "v1", | |
"lossy": true, | |
"enabled": true, | |
"ttl": 604800, | |
"s3": { | |
"key": "<S3 Bucket Key>", | |
"secret": "<S3 Bucket Secret>", |
View ForceHTTPSVarnish3.vcl
sub vcl_recv { | |
if (req.http.X-Forwarded-Proto !~ "https") { | |
error 850 "Moved permenantly"; | |
} | |
} | |
sub vcl_error { | |
if(obj.status == 850) { | |
set obj.http.Location = "https://" + req.http.host + req.url; | |
set obj.status = 301; |
View HTMLStreaming.vcl
#Example of HTML Streaming. This gist involves both Varnish and nginx LUA reverse proxies | |
#Varnish: | |
sub vcl_recv { | |
# Do not stream on non-get requests | |
if (req.method != "GET" && req.method != "HEAD" && req.method != "PURGE") { | |
return (pass); | |
} | |
# By defaul disable holepunch unless below cases fall through (do not modify this line) |
NewerOlder