Answer the question
In order to leave comments, you need to log in
How to replace VirtualHost/SERVER_ADDR with X_SERVER_IP header value in Apache 2.4?
Hello.
There is a server Apache 2.4 + Nginx 1.10.
As usual, Nginx proxies requests to Apache, while the directive is written proxy_set_header X-Server-IP $server_addr;
in the Apache vhost config is registered with the directive VirtualHost 127.0.0.1:8080
, it cannot be changed, there are a lot of configs and they are generated by third-party software.
Then there is PHP, which tries to get the $_SERVER['SERVER_ADDR'] variable, but only gets 127.0.0.1 into it, and not the virtual host's real IP. You can, of course, get $_SERVER['HTTP_X_SERVER_IP'], but the variable is used in third-party software, which I would not want to edit after each update.
Question: how in Apache to replace the VirtualHost value with the X-Server-IP header so that the correct IP gets into $_SERVER['SERVER_ADDR']?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question