From a9fbb83be057ccdbb6687235ccd56722a787c549 Mon Sep 17 00:00:00 2001 From: PJ Date: Mon, 31 Jul 2023 14:15:40 +0100 Subject: [PATCH] Add VCL snippet for client geo header (#19780) * add VCL snippet for client geo header * update snippet with docs + covering more edge cases --- config/fastly/snippets/client_geolocation.vcl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 config/fastly/snippets/client_geolocation.vcl diff --git a/config/fastly/snippets/client_geolocation.vcl b/config/fastly/snippets/client_geolocation.vcl new file mode 100644 index 000000000..35ec353fe --- /dev/null +++ b/config/fastly/snippets/client_geolocation.vcl @@ -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; + } +}