Is the GeoIP Redirect module compatible with Varnish?

Is the GeoIP Redirect module compatible with Varnish?

Starting from version 1.7.0, the GeoIP Redirect extension does work with Varnish cache, but requires a few changes in the web server configuration for that. Please contact your hosting provider on this matter or follow the steps below.

Step 1. Open the Varnish configuration fileUsually, it is placed here:

/usr/varnish/default.vcl

Step 2. Kindly insert the code below into default.vcl in the vcl_recv section before the last line after all existing instructions:

if (req.http.Cookie !~ "geoip_redirect_for_varnish" 
        && req.url !~ "^/(pub/)?(media|static)/.*" 
        && req.url !~ "/graphql"
        && !req.http.x-long-cache
        && req.http.X-Requested-With != "XMLHttpRequest"
    ) {
        return (pass);
    } 

Step 3. Once done, kindly restart Varnish.

Kindly note that our extension doesn't influence the performance of Varnish itself. The server configuration above ensures receiving the correct IP address of the customer and thus, redirecting them to the correct store (according to the extension settings). 

      • Related Articles

      • How does the GeoIP Redirect module work with Cloudflare?

        There is a known issue with using the GeoIP Redirect module with Cloudflare. It occurs due to the actual IP address of a customer being replaced by the proxy IP. To introduce compatibility between Cloudflare and the GeoIP Redirect module, follow the ...
      • What is the difference between GeoIP Redirect and Store Switcher?

        GeoIP Redirect and Store Switcher are the two names of the same Amasty extension, they deliver identical functionality. Several product pages have been created to reveal the functionality of the module from different angles.
      • Why GeoIP Redirect module does not work when using Amasty Service?

        In order for the module to redirect customers correctly, the IP database should be first imported in Stores → Configuration → Amasty Extensions → GeoIP Data. In case Amasty Service is used for IP Database Update Settings in Stores → Configuration → ...
      • Does WebP work with Varnish?

        WebP images are compatible with the Varnish cache. The compatibility was introduced to the module in version 2.1.2. Make sure that you have the latest version of the extension installed. To make WebP images load on the website, it is required to ...
      • Why doesn't redirect function on the frontend?

        This guide outlines key areas to examine to ensure your redirects operate smoothly. 1. Verify Redirects with GET Parameters Firstly, it is essential to verify whether redirects function when using a GET parameter. This check helps to rule out the ...