Skip to content

Instantly share code, notes, and snippets.

Avatar

section-io-gists

View GitHub Profile
@section-io-gists
section-io-gists / pagespeed-requirement.vcl
Created Mar 15, 2017
Using the PageSpeed module alongside Varnish, you will need to configure Varnish to handle PageSpeed optimizations.
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,}\.") {
@section-io-gists
section-io-gists / ForceHTTPSVarnish4.vcl
Last active Jul 29, 2020
Varnish 4.x to force HTTPS
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
}
@section-io-gists
section-io-gists / wordpressConfig.vcl
Last active Jan 13, 2020
A full Wordpress Varnish configuration to copy paste into section.io
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.
@section-io-gists
section-io-gists / CustomMaintenancePage.vcl
Last active Jan 9, 2020
Varnish 4 - Custom maintenance page
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>"
}
@section-io-gists
section-io-gists / kraken.json
Created May 21, 2019
Kraken Module configuration in Section
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>",
@section-io-gists
section-io-gists / ForceHTTPSVarnish3.vcl
Last active Apr 21, 2019
Force traffic to HTTPS in Varnish 3.x
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;
@section-io-gists
section-io-gists / HTMLStreaming.vcl
Last active Mar 25, 2019
HTML Streaming solution to cache the HEAD of HTML
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)