1

So I'm migrating some legacy PHP project from an old server to a new one. New server is using Debian 10 / Nginx / Apache 2.4 / PHP 5.6.40

I've set up everything like I'm used to, using mod_rpaf to override the remote IP address with the one coming from nginx in X-Real-IP. I see the correct address in $_SERVER['HTTP_X_REAL_IP'] in PHP, but $_SERVER['REMOTE_ADDR'] is still '127.0.0.1'

Things I tried already:

  • commenting out <IfModule rpaf_module> in the rpaf.conf file (some old answers suggested that the module name could be incorrect);
  • changing configuration directives from RPAFenable, etc. to RPAF_Enable and so on - apache refuses to start so obviously the RPAFenable format is correct;
  • disabling mod_rpaf and using mod_remoteip instead - no effect;
  • using PHP's auto_prepend_file ini file option to replace REMOTE_ADDR with HTTP_X_REAL_IP - doesn't have any effect despite code being executed (checked it with echo '1';).

So I'm quite in a dead end and see no other option but just using isset($_SERVER['HTTP_X_REAL_IP']) && $_SERVER['HTTP_X_REAL_IP'] || $_SERVER['REMOTE_ADDR'] ugly constructions everywhere in code...

But I still hope there's something I'm missing.

Update: In fact, auto_prepend_file option worked, but feels kinda hacky... I'd still like to find a better option.

mephisto123
  • 1,400
  • 13
  • 38

0 Answers0