1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.4 Many IPs appear as 127.0.0.1

Discussion in 'Troubleshooting and Problems' started by Valvar, Feb 14, 2015.

  1. Valvar

    Valvar Member

    We've been having a lot of trouble with spam recently. I suspect it is because IPs that would normally be blacklisted appear as local IPs. Has this happened to anyone else, and is there any way to fix this behaviour? I have a feeling that it may be related to SSL, but I have no clue...
     
  2. Mike

    Mike XenForo Developer Staff Member

    The only way this would happen is if you are doing something in config.php to change the IP (or an add-on is). Or if that is actually the real IP (requests coming from the same server). A third option would actually be for this to be from the server itself misreporting, likely due to a misconfiguration.

    Have you setup anything in config.php to change $_SERVER['REMOTE_ADDR']? Does this still happen with add-ons disabled?
     
    Valvar likes this.
  3. Valvar

    Valvar Member

    I only have the database access information in my config.php. The problem remains when I disable addons (with
    $config['enableListeners'] = 0; ). Strangely enough bots seem to always have their IP correctly reported, while most users show as 127.0.0.1.
     
  4. Mike

    Mike XenForo Developer Staff Member

    Does your own IP show correctly on your posts? If not, go to admin.php?tools/phpinfo and look for "REMOTE_ADDR" entries. What do they list?
     
    Valvar likes this.
  5. Valvar

    Valvar Member

    My own IP is listed as 127.0.0.1 localhost under post information, and REMOTE_ADDR contains 127.0.0.1.
     
  6. RobParker

    RobParker Well-Known Member

    Are you using a reverse proxy type thing? When we had Apache/NGINX in a certain config we were seeing the same thing.
     
  7. Valvar

    Valvar Member

    Beyond the built-in image and link proxy, I am not aware of having activated any such feature...
     
  8. Mike

    Mike XenForo Developer Staff Member

    It's worth contacting your host about this then. It would be down to how they have configured the system (presuming they have).
     
    Valvar likes this.
  9. Valvar

    Valvar Member

    I got the following response from my host:

    How can I make use of this solution? I suspect that it may be useful to others, as NearlyFreeSpeech (my host) is fairly widely used, and there may be other hosts using similar implementations of SSL.

    Thanks!
     
  10. Mike

    Mike XenForo Developer Staff Member

    That's a weird setup and not one that I've heard of before. Can you confirm that the _SERVER["REMOTE_HOST"] entry on the phpinfo page mentioned above has the correct IP?
     
  11. Valvar

    Valvar Member

    The contents of _SERVER["REMOTE_HOST"] are: 81.***.***.**3, 127.0.0.1 (the stars are just censored digits from my IP, which does indeed display correctly). So it lists both my IP and 127.0.0.1 after a comma.
     
  12. Mike

    Mike XenForo Developer Staff Member

    Try adding this to your config.php:

    Code:
    if (!empty($_SERVER['REMOTE_HOST']))
    {
        $ips = explode(',', $_SERVER['REMOTE_HOST']);
        $_SERVER['REMOTE_ADDR'] = trim($ips[0]);
    }
     
    Last edited: Feb 16, 2015
    Valvar likes this.
  13. Valvar

    Valvar Member

    That causes the entire forum to thow:

    Code:
    Parse error: syntax error, unexpected '$_SERVER' (T_VARIABLE) in /home/public/library/config.php on line 21
     
  14. Mike

    Mike XenForo Developer Staff Member

    Oops, I edited the code to be correct -- was missing a ",".
     
    Valvar likes this.
  15. Valvar

    Valvar Member

    Yes, this does seem to have fixed it! Thank you very much!
     

Share This Page