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
sub vcl_recv { | |
# section.io Edge node automatically performs GEO IP (and city) lookup on every request. | |
# We create a request header called "section-io-geo-country" that you can leverage | |
if (req.http.section-io-geo-country ~ "^(AU|NZ)$") { | |
# Australia and New Zealand | |
#return (synth(802, "https://www.domain.com.au/")); | |
} else if (req.http.section-io-geo-country ~ "^(US|CA|MX)$") { | |
# US, Canada and Mexico | |
#return (synth(802, "http://www.domain.com/")); |
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
sub vcl_recv { | |
# Strip browser side tracking script to improve cache hit rate | |
if (req.url ~ "[?&](utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl|mc_cid|mc_eid)=") { | |
set req.url = regsuball(req.url, "(?:(\?)?|&)(?:utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl|mc_cid|mc_eid)=[^&]+", "\1"); | |
set req.url = regsuball(req.url, "(?:(\?)&|\?$)", "\1"); | |
} | |
} |
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
#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) |
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
sub vcl_recv { | |
# Happens before we check if we have this in cache already. | |
# | |
# Typically you clean up the request here, removing cookies you don't need, | |
# rewriting the request, etc. | |
if (req.method != "GET" && req.method != "HEAD" && req.method != "PURGE") { | |
return (pass); | |
} | |
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
sub vcl_recv { | |
# section.io Edge node automatically performs GEO IP (and city) lookup on every request. | |
# We create a request header called "section-io-geo-country" that you can leverage | |
if (req.http.section-io-geo-country ~ "^RU$") { | |
# Block Russia | |
error 403 "Forbidden"; | |
} | |
} |
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
# Please note: There is an underlying default Varnish behavior that occurs after the VCL logic | |
# you see below. You can see the bultin code here | |
# https://github.com/varnishcache/varnish-cache/blob/5.1/bin/varnishd/builtin.vcl | |
# | |
# 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. | |
# Marker to tell the VCL compiler that this VCL has been adapted to the | |
# new 4.0 format. | |
vcl 4.0; |
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
#vcl 4.0; | |
# comment the following imports if imported elsewhere | |
import cookie; | |
import header; | |
import std; | |
import var; | |
sub vcl_synth { | |
if (resp.status == 837) { |
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
sub vcl_recv { | |
if (req.http.host !~ "www") { | |
return (synth(850, "Moved Permanently")); | |
} | |
} | |
sub vcl_synth { | |
if(resp.status == 850) { | |
set resp.http.Location = "https://www." + req.http.host + req.url; | |
set resp.status = 301; |
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
sub vcl_recv { | |
if (req.http.host !~ "www") { | |
error 850 "Moved Permanently"; | |
} | |
} | |
sub vcl_error { | |
if(obj.status == 850) { | |
set obj.http.Location = "https://www." + req.http.host + req.url; | |
set obj.status = 301; |
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
sub vcl_recv { | |
# Set a X-Language header to spanish is the client is from a spanish speaking country | |
if (req.http.section-io-geo-country ~ "^(AR|BO|CL|CO|CR|CU|DO|EC|SV|GQ|GT|HN|MX|NI|PA|PY|PE|ES|UY|VE)$") { | |
set req.http.X-Language = "Spanish"; | |
} else { | |
set req.http.X-Language = "English"; | |
} | |
} | |
sub vcl_hash { |