20 Sep 21
When it comes to positioning your content on the Internet, you can publish different content on the same website based on the user’s location. This specific functionality is the website request geolocation of the final user. With this, the owners of the content can define different rules, such as blocking or unblocking content according to the user’s geographical location.
The foundation of this functionality is geolocation, which is simply the ability to determine the real geographic location of a user. It acts as a radar when you access the Internet from a mobile phone, computer or tablet. Depending on what the radar detects, a website will show different kinds of content if the geoblocking or geographical restriction is activated (also often known as “geofencing”).
The goal of this post is for you to understand what lies behind all of this and how Transparent Edge allows you to use this feature in a simple way. This is useful to limit the visualization of certain content, but it’s particularly important when you want to sell something through an e-commerce store, allowing you to set prices according to the country.
At Transparent Edge, by default, we geolocate every request that passes through our systems, always sending a header to the origin with the country code from which the request was made. This header is the geo_country_code.
For this functionality we integrate with all the databases homologated by the major players. GeoIP2 Enterprise Database. One of them for example has a country accuracy rate of 99,8%.
It’s possible to send other data that this kind of database provides, set it as an http header and send it to the origin, i.e. the city, but we have to consider that the city-level of accuracy in this database for Spain is around 75%.
The header geo_country_code is the country code based on the ISO 3166 standard.
If the system was unable to determine the user’s IP address, it will send the string “Unknown” within the header.
Through this header, we can actually make any decision, such as performing a redirection, providing specific content for that country in particular, or simply geoblocking content.
For this last option, we will go into our panel, then to Provisioning, VCL Config, and in the advanced section, we will duplicate the configuration that is being produced at that time and we will enter the geoblocking code within the function vcl_recv.
To understand how the header “TCDN-Command” works, please refer to this link.
Similarly, we can redirect a website to a URL or specific site based on the user’s location, for example: