News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

SMF not always picking up the right IP

Started by Oldiesmann, April 17, 2022, 04:08:08 PM

Previous topic - Next topic

Oldiesmann

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.
Michael Eshom
Christian Metal Fans

Arantor

Using CloudFlare or some other proxy? If so you want to use the setting for reverse proxy to pick it up.

Oldiesmann

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
Michael Eshom
Christian Metal Fans

Oldiesmann

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.
Michael Eshom
Christian Metal Fans

Oldiesmann

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)
Michael Eshom
Christian Metal Fans

Advertisement: