Add VCL snippet for client geo header (#19780)
* add VCL snippet for client geo header * update snippet with docs + covering more edge cases
This commit is contained in:
parent
c869aac081
commit
a9fbb83be0
1 changed files with 18 additions and 0 deletions
18
config/fastly/snippets/client_geolocation.vcl
Normal file
18
config/fastly/snippets/client_geolocation.vcl
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
sub vcl_recv {
|
||||
declare local var.code STRING;
|
||||
|
||||
if (client.geo.country_code != "**") { // Indicates a reserved country block
|
||||
set var.code = client.geo.country_code;
|
||||
|
||||
if (
|
||||
client.geo.region != "NO REGION" && // The country has no regions
|
||||
client.geo.region != "AOL" && // For some reason the ISP AOL uses itself as a region
|
||||
client.geo.region != "?" && // The country has regions, but it is absent/indeterminate
|
||||
client.geo.region != "***" // Indicates a reserved region block
|
||||
) {
|
||||
set var.code = var.code + "-" + client.geo.region;
|
||||
}
|
||||
|
||||
set req.http.HTTP_CLIENT_GEO = var.code;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue