Simple Machines Community Forum

SMF Support => Server Performance and Configuration => Topic started by: Oldiesmann on April 17, 2022, 04:08:08 PM

Title: SMF not always picking up the right IP
Post by: Oldiesmann on April 17, 2022, 04:08:08 PM
Noticed a weird issue on my server. In several cases, SMF is showing the server IP as the user's IP address (so it's not picking the HTTP_X_FORWARDED_FOR / HTTP_X_REAL_IP one), including me. It doesn't happen all the time or with every user though. On my seniors forum, for many users it will show the correct IP in their profile.

On my new forum, both times someone has signed up, the list of members awaiting approval in the admin center has shown the server IP as their IP. In my profile on both that forum and the seniors forum (as well as on a 2.1 test board on the same server but different domain), it shows my IP as the server IP.

What's even stranger though is that a 2.0 test board I also have on the server shows the correct IP even though I haven't done anything different with the configuration of that site than I have with any of the others.
Title: Re: SMF not always picking up the right IP
Post by: Arantor on April 17, 2022, 05:03:46 PM
Using CloudFlare or some other proxy? If so you want to use the setting for reverse proxy to pick it up.
Title: Re: SMF not always picking up the right IP
Post by: Oldiesmann on April 17, 2022, 08:41:14 PM
I've got the standard nginx reverse proxy for Apache setup (Apache passing static stuff to nginx). Phpinfo shows both the forwarded for and real IP $_SERVER variables so I'm not sure what else I should tweak. It also only seems to happen for some users and not all of them. The seniors forum I run shows 6 of us with that IP but some other users have their proper IPs
Title: Re: SMF not always picking up the right IP
Post by: Oldiesmann on April 22, 2022, 01:40:40 AM
Still need to look into this further. The seniors site shows the correct IPs for most users but I have that one set to run PHP from nginx (because on the old server running it from Apache caused problems - I never figured out why). The auto-generated nginx config file is set to pass the correct IP via the forwarded for and real IP headers (each domain has its own nginx config file that's automatically generated based on your desired configuration). I'm not sure why SMF is ignoring those and going with the server's IP instead. I did try choosing the specific header and specifying the server's IP address as the proxy IP in the SMF admin center but it doesn't seem to have made any difference.
Title: Re: SMF not always picking up the right IP
Post by: Oldiesmann on April 24, 2022, 05:30:30 PM
Anyone else have thoughts/suggestions on this? I've verified that the server is sending the real IP in the proper headers but SMF wants to use the server IP instead. This also happens for a few users who have IPv6 (it's using the server's IPv6 instead of the correct one)