Skip to content
This repository has been archived by the owner on Oct 29, 2020. It is now read-only.

Fastly Global Header Setup

Diego Lorenzo edited this page May 25, 2016 · 10 revisions

Fastly Headers and Mappings

Format:

Header-Sent-To-App: Fastly Source

Request Headers

http.X-Fastly-Country-Code: geoip.country_code
http.X-Fastly-City: geoip.city
http.X-Fastly-Latitude: geoip.latitude
http.X-Fastly-Longitude: geoip.longitude
http.X-Fastly-Region: geoip.region
http.X-Fastly-Country-Name: geoip.country_name

Response Headers

http.X-Fastly-Country-Code-Client: geoip.country_code

However, we only really take into account the X-Fastly-Country-Code header. While the others can also be added our platform doesn't currently use them for anything, but might in the future.

Quick setup for local testing

Install ModHeader (or any other extension for modifying browser headers) https://chrome.google.com/webstore/detail/modheader/idgpnmonknjnojddfkpgkljpfnnfcklj?hl=en

Assuming you're running ModHeader, you can import the following profiles:

Brasília, Brazil

{"title":"Brasília, Brazil","hideComment":true,"headers":[{"enabled":true,"name":"X-Fastly-City","value":"Brasília","comment":""},{"enabled":true,"name":"X-Fastly-Country-Code","value":"BR","comment":""},{"enabled":true,"name":"X-Fastly-Country-Name","value":"Brazil","comment":""},{"enabled":true,"name":"X-Fastly-Latitude","value":"15.794","comment":""},{"enabled":true,"name":"X-Fastly-Longitude","value":"47.833","comment":""},{"enabled":true,"name":"X-Fastly-Region","value":"","comment":""}],"respHeaders":[],"filters":[],"appendMode":""}

Toronto, Canada

{"title":"Toronto, Canada","hideComment":true,"headers":[{"enabled":true,"name":"X-Fastly-City","value":"Toronto","comment":""},{"enabled":true,"name":"X-Fastly-Country-Code","value":"CA","comment":""},{"enabled":true,"name":"X-Fastly-Country-Name","value":"Canada","comment":""},{"enabled":true,"name":"X-Fastly-Latitude","value":"43.653","comment":""},{"enabled":true,"name":"X-Fastly-Longitude","value":"-79.383","comment":""},{"enabled":true,"name":"X-Fastly-Region","value":"","comment":""}],"respHeaders":[],"filters":[],"appendMode":""}

Tokyo, Japan

{"title":"Tokyo, Japan","hideComment":true,"headers":[{"enabled":true,"name":"X-Fastly-City","value":"Tokyo","comment":""},{"enabled":true,"name":"X-Fastly-Country-Code","value":"JP","comment":""},{"enabled":true,"name":"X-Fastly-Country-Name","value":"Japan","comment":""},{"enabled":true,"name":"X-Fastly-Latitude","value":"35.683","comment":""},{"enabled":true,"name":"X-Fastly-Longitude","value":"139.683","comment":""},{"enabled":true,"name":"X-Fastly-Region","value":"","comment":""}],"respHeaders":[],"filters":[],"appendMode":""}

Mexico City, Mexico

{"title":"Mexico City, Mexico","hideComment":true,"headers":[{"enabled":true,"name":"X-Fastly-City","value":"Mexico City","comment":""},{"enabled":true,"name":"X-Fastly-Country-Code","value":"MX","comment":""},{"enabled":true,"name":"X-Fastly-Country-Name","value":"Mexico","comment":""},{"enabled":true,"name":"X-Fastly-Latitude","value":"19.433","comment":""},{"enabled":true,"name":"X-Fastly-Longitude","value":"99.133","comment":""},{"enabled":true,"name":"X-Fastly-Region","value":"","comment":""}],"respHeaders":[],"filters":[],"appendMode":""}

New York, USA

{"title":"New York, USA","hideComment":true,"headers":[{"enabled":true,"name":"X-Fastly-City","value":"New York","comment":""},{"enabled":true,"name":"X-Fastly-Country-Code","value":"US","comment":""},{"enabled":true,"name":"X-Fastly-Country-Name","value":"United States","comment":""},{"enabled":true,"name":"X-Fastly-Latitude","value":"40.739","comment":""},{"enabled":true,"name":"X-Fastly-Longitude","value":"-73.983","comment":""},{"enabled":true,"name":"X-Fastly-Region","value":"NY","comment":""}],"respHeaders":[],"filters":[]}

NOTE: I highly recommend for those using ModHeader to also take advantage of the Profile feature for quickly switching between countries.

If you're not running ModHeader you can manually add the following header to whatever extension you are using, and switch out the value depending on the country you are trying to spoof from (BR, CA, JP, MX, US, etc...):

X-Fastly-Country-Code: US

Other Country Codes

You can refer to this list of official country codes to try spoofing other countries. Keep in mind we specifically use the alpha-2 codes.

Clone this wiki locally