We've been making changes to how we organize and display our docs. Our work isn't done but we'd love your feedback.
Getting started
Basics
Domains & Origins
Performance

Configuration
Basics
Conditions
Dictionaries
Domains & Origins
Request settings
Cache settings
Headers
Responses
Performance
Custom VCL
Image optimization
Video

Security
Access Control Lists
Monitoring and testing
Securing communications
TLS
Web Application Firewall

Integrations
Logging endpoints
Non-Fastly services

Diagnostics
Streaming logs
Debugging techniques
Common errors

Account info
Account management
Billing
User access and control

Reference

    Creating location-based tagging

      Last updated August 09, 2018

    You can set custom HTTP headers in your varnish configuration (VCL) based on the variables we expose. Use the geolocation features we have built into Varnish to create location-based tagging. We provide a list of geographic information based on a client's IP address. For a complete list of available geolocation variables, read about which geolocation features are accessible via VCL.

    In the example below, an HTTP header Fastly-GeoIP-CountryCode is created with the two letter country code of the client's IP address using VCL Snippets.

    1. Log in to the Fastly web interface and click the Configure link.
    2. From the service menu, select the appropriate service.
    3. Click the Configuration button and then select Clone active. The Domains page appears.
    4. Click the VCL Snippets link. The VCL Snippets page appears.
    5. Click Create Snippet. The Create a VCL snippet page appears.

      vcl snippet window

    6. In the Name field, type an appropriate name (e.g., GeoLocation Header).
    7. From the Type controls, select within subroutine.
    8. From the Select subroutine menu, select recv (vcl_recv).
    9. In the VCL field, add the following condition:

      1
      
         set req.http.Fastly-GeoIP-CountryCode = client.geo.country_code;
      
    10. Click Create to create the snippet.
    11. Click the Activate button to deploy your configuration changes.
    Back to Top