News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

X-Real-Ip/X-Forwarded-For support?

Started by rayarachelian, January 20, 2019, 11:43:49 AM

Previous topic - Next topic

rayarachelian

I'm running SMF 2.0.15 in Docker behind an nginx proxy, which adds X-Forwarded-For and X-Real-Ip headers, however SMF shows all users as logged in from the docker proxy IP (172.16.x.x.)

How do I get it to recognize the X-Forwarded-For or X-Real-Ip headers and use those for users instead?

I'm using a modified version of this repo: hxxp:github.com/vortexau/SMF-Docker [nonactive] which creates an Apache 2 instance where the default website is pointing at /var/www/html inside the container.

On the outside, nginx does a reverse proxy to the container and adds these headers.

vbgamer45

This might be hepful https://support.cloudflare.com/hc/en-us/articles/200170706-How-do-I-restore-original-visitor-IP-with-Nginx-

You can also add to your settings.php a php code that checks if those headers are set then overwrite the php ip address.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

rayarachelian

This seems to have worked perfectly with only minor changes on the apache side. (For anyone else reading this, again, nginx is on the outside acting as a reverse proxy, apache is on the inside of the Docker container, and runs SMF)

1. enable remoteip by linking mods-available/remoteip to mods-enabled.
2. add RemoteIPHeader X-Real-IP to httpd.conf
 

Advertisement: