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.request != "GET" && req.request != "HEAD" && req.request != "PURGE") { | |
return (pass); | |
} | |
// Rest of vcl_recv code | |
return(lookup); | |
} | |
sub vcl_fetch { | |
if (req.request != "GET" && req.request != "HEAD" && req.request != "PURGE") { |
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 the request isn't GET|HEAD|PURGE { | |
skip the rest of vcl_recv code | |
} | |
// Rest of vcl_recv code | |
perform a lookup in cache | |
} | |
sub vcl_backend_response { | |
if the request isn't GET|HEAD|PURGE { |
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.method != "GET" && req.method != "HEAD" && req.method != "PURGE") { | |
return (pass); | |
} | |
// Rest of vcl_recv code | |
return(hash); | |
} | |
sub vcl_backend_response { |
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 { |
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 { | |
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
#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
# 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
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"; | |
} | |
} |