Decorating origin requests with GeoIP

Add GeoIP data about the client browser as extra headers in any requests from Fastly to your origin.


Use this solution in your VCL service (click RUN below to test this solution or clone it to make changes):


Use this solution in your Compute@Edge service:

  1. Rust
if let Some(geo) = req.get_client_ip_addr().and_then(geo_lookup) {
req.set_header("client-geo-continent", format!("{:?}", geo.continent()));
req.set_header("client-geo-country", geo.country_code());
req.set_header("client-geo-latitude", geo.latitude().to_string());
req.set_header("client-geo-longitude", geo.longitude().to_string());