Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$_SERVER['REMOTE_ADDR'] doesn't work with php-fpm and nginx

Tags:

php

nginx

I don't know why with nginx this variable $_SERVER['REMOTE_ADDR'] doesn't echo an IP. On every other web server it works as it should.

Any suggestions?

like image 848
B.Petrus Avatar asked Dec 06 '25 12:12

B.Petrus


1 Answers

I suspect it has something to do with the interface between nginx (the webserver) and fastcgi, which is the API in which PHP is running.

According to your info provided, the Server API is: FPM/FastCGI

I suggest you take a hard look at the details of how PHP is installed with nginx (you have not provided any).

If you do not require the performance of nginx, then you may find a pragmatic solution is to just use apache. I use nginx as a reverse proxy in front of apache, but that introduces some additional issues with getting the REMOTE_ADDR passed to PHP (notably, mod_rpaf).

Good luck!

like image 77
gahooa Avatar answered Dec 09 '25 01:12

gahooa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!