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:
PJ 2023-07-31 14:15:40 +01:00 committed by GitHub
parent c869aac081
commit a9fbb83be0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View 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;
}
}