• Resolved Tricky.Dicky

    (@trickydicky-1)


    I just had this problem and fixed it, so thought I would post encase it helps someone. I am running WP on AWS with Varnish caching the site (BTW Varnish is awesome!)

    I had an issue with the plugin detecting all IP addresses as the client id 127.0.0.1. This is because it is detecting the ip address of varnish in the header. In my case a misconfiguration of the varnish .vcl was causing the correct client ip to not be forwarded. So to fix I added:

    remove req.http.X-Forwarded-For;
       set    req.http.X-Forwarded-For = client.ip;

    to sub vcl_recv { in the .vcl.

    Hope this helps someone. Let me know if you need clarification.

    https://wordpress.org/plugins/geoip-detect/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Benjamin Pick

    (@benjamin4)

    Not sure if I understand the config rule correctly. Does it change the header X-Forwarded-For? I always thought reverse proxies do this by default.

    (BTW the plugin already supports multiple reverse proxies, e.g. if your varnish would be behind a Cloudflare setup, HOWEVER this is not exposed to the options UI yet.)

    Thread Starter Tricky.Dicky

    (@trickydicky-1)

    Yes it sets X-Forwarded-For so that when you select to use reverse proxy it knows the ip. Not sure if it’s my specific server/varnish configuration, but basically that rule allows the IP address to be passed through varnish. Without it the function was just returning 127.0.0.1, and HTTP_X_FORWARDED_FOR was not even present in the PHP var_dump($_SERVER).

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Detecting 127.0.0.1/host IP with Varnish’ is closed to new replies.