How can I make Varnish Cache compatible with redirects?

To ensure full compatibility of GeoIP redirect module with Varnish Cache, you need to change the settings on the web server side. 

To change the settings, you have 2 options:

  1. Contact the hosting provider and tell them what needs to be changed in the web server configuration.
  2. Change the configuration files yourself (nginx.conf for nginx, .htaccess for apache). To do this, you need to have root access. Restart the server after changing the setting.

For nginx, add the following code anywhere in the nginx.conf file:

set_real_ip_from <varnish-ip>;

For apache, add the following string anywhere in the .htaccess file:

RemoteIPTrustedProxy <varnish-ip>;

Here, <varnish-ip> is the IP address of the varnish server.

See more details on GeoIP Redirect for Magento 2 page

User Guide

How can we help you?

Didn’t you find the answer to your question? We are always happy to help you out.

© 2009-2024 Amasty. All Rights Reserved.