After 5 hours trying to solve the problem and read any tutorial i have found, i ask here for help.
I have an Nginx Reverse Proxy
Server that points to my Apache
Web Server, but on Apache
i got just the IP address
from Nginx reverse proxy
server not visitors ip.
My nginx proxy file: /etc/nginx/sites-available/proxy.conf
proxy_pass http://MYIPADDRESS;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
On Apache i have added to /etc/apache2/apache2.conf
file:
RemoteIPHeader X-Forwarded-For
and replaced
LogFormat "%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
with
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %{X-Forwarded-For}i" combined
a2enmod remoteip
also enabled
Also in Nginx /var/log/nginx/access.log
file i got always just localhost
IP like:
127.0.0.1 - - [27/Jan/2020:23:53:07 +0800] "GET...
Also have tried to add to /etc/nginx/nginx.conf
:
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For
If i run on my Webserver now an PHP Script in Browser:
<?php
echo 'User IP - '.$_SERVER['REMOTE_ADDR'];
?>
I just got the Reverse Proxy Servers IP and its the same for whole server.
Both Servers OS are Debian 9, any one an idea? Many Thanks!
First of all, make sure you installed and enabled mod_remoteip apache module.
I use the following configuration on my server.
In httpd.conf:
LoadModule remoteip_module modules/mod_remoteip.so
RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 127.0.0.1
In nginx site configuration file:
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.