Created
December 14, 2017 22:25
-
-
Save section-io-gists/7d2d9da64d3fb2f82aa4b6453fa7ce95 to your computer and use it in GitHub Desktop.
Revisions
-
section-io-gists created this gist
Dec 14, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ acl whitelist_geo { "13.13.22.30"; "123.39.96.0"/24; } acl geo_to_au { "1.1.22.30"; "133.29.93.0"/30; } 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 # Force IP addresses from ACL to AU if((std.ip(req.http.True-Client-IP, "0.0.0.0") ~ geo_to_au) { # Australia and New Zealand #return (synth(802, "https://www.domain.com.au/")); } # Only GEO redirect if IP address is not in whitelist ACL if(!(std.ip(req.http.True-Client-IP, "0.0.0.0") ~ whitelist_geo) { 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/")); } else { # UK and the rest of the world #return (synth(802, "http://www.domain.co.uk")); } } } sub vcl_synth { if (resp.status == 802) { set resp.http.Location = resp.reason; set resp.status = 302; return (deliver); } }