Author Topic: X-Real-Ip/X-Forwarded-For support?  (Read 247 times)

Offline rayarachelian

  • Newbie
  • *
  • Posts: 5
X-Real-Ip/X-Forwarded-For support?
« on: January 20, 2019, 11:43:49 AM »
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: [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.

Offline vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 21,382
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: X-Real-Ip/X-Forwarded-For support?
« Reply #1 on: January 20, 2019, 12:24:10 PM »
This might be hepful

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! -  Paid Modifications for SMF

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

Offline rayarachelian

  • Newbie
  • *
  • Posts: 5
Re: X-Real-Ip/X-Forwarded-For support?
« Reply #2 on: January 21, 2019, 06:32:54 PM »
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