Geo IP Redirect Module Compatibility with Varnish

Is the Geo IP Redirect module compatible with Varnish?

Starting from version 1.7.0, the Geo IP 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).