Below are two very common web server implementations and how a site administrator could configure custom logging for the country of their visitors. Visitor traffic geolocation information can be captured in origin server logging. This Managed Transform adds HTTP request headers with location information for the visitor's IP address, such as city, country, continent, longitude, and latitude.īesides using the Managed Transform, you can also enable the IP Geolocation feature in the Cloudflare dashboard ( Network app), which will only add a request header for the visitor's country.Ĭapturing IP geolocation data in server logs
The recommended procedure to enable IP geolocation information is to enable the Add visitor location headers Managed Transform. Currently, the IPv4 information is more robust, but we expect the IPv6 data to improve rapidly. This header is not visible to visitors in the site's HTTP response.Ĭloudflare includes country code information for both IPv4 and IPv6 addresses. The country code value is passed along in the CF-IPCountry request header to the origin web server.
T1 - Used for clients using the Tor network.XX - Used for clients without country code data.Besides ISO country codes, Cloudflare uses the following special country codes: This allows site administrators to capture their visitor's IP location in server logging and/or application logic. Capturing IP geolocation data in application logicĬloudflare can include the country code of the visitor's IP address (in ISO 3166-1 Alpha 2 format) with each request between Cloudflare and the upstream origin web server.Capturing IP geolocation data in server logs.