Geolocation VCL features
Fastly exposes a number of geographic variables for you to take advantage of inside VCL for both IPv4 and IPv6 client IPs.
- client.as.name — The name of the organization associated with
- client.as.number — The autonomous system (AS) number associated with this IP address.
- client.geo.area_code — The telephone area code associated with the IP address.
- client.geo.city.ascii — City or town name, encoded using ASCII encoding.
- client.geo.city.utf8 — The city or town name associated with the IP address, encoded using the UTF-8 character encoding.
- client.geo.city — Alias of
- client.geo.conn_speed — The type of connection speed associated with the IP address.
- client.geo.continent_code — A two-character code representing the continent associated with the IP address.
- client.geo.country_code — A two-character ISO 3166-1 country code for the country associated with the IP address.
- client.geo.country_code3 — A three-character ISO 3166-1 alpha-3 country code for the country associated with the IP address.
- client.geo.country_name.ascii — An alias of
- client.geo.country_name.utf8 — The country name associated with the IP address, encoded using the UTF-8 character encoding.
- client.geo.country_name — The country name associated with the IP address, encoded using the ASCII character encoding (a lowercase ASCII approximation of the original string with diacritics removed).
- client.geo.gmt_offset — The time zone offset from coordinated universal time (UTC) for the
client.geo.cityassociated with the IP address.
- client.geo.latitude — The latitude associated with the IP address.
- client.geo.longitude — The longitude associated with the IP address.
- client.geo.metro_code — The metro code associated with the IP address.
- client.geo.postal_code — The postal code associated with the IP address.
- client.geo.region — The ISO 3166-2 region code associated with the IP address.
- server.datacenter — A code representing one of Fastly's POP locations.
- server.region — A code representing the general region of the world in which the POP location resides.
NOTE: While Fastly exposes these geographic variables, we cannot guarantee their accuracy. The variables are based on available geographic data and are intended to provide an approximate location of where requests might be coming from, rather than an exact location. The postal code associated with an IP address is the most granular level of geographic data available.
NOTE: Geolocation information, including data streamed by our log streaming service, is intended to be used only in connection with your use of Fastly services. Use of geolocation data for other purposes may require the permission of a IP geolocation dataset vendor, such as Digital Element.
TIP: If you're updating your configurations from older version of the geolocation variables, be sure to read our migration guide.
Using geographic variables with shielding
If you have shielding enabled, you should set the following variable before using geographic variables:
1 set client.geo.ip_override = req.http.Fastly-Client-IP;