Nginx - get real IP through X-Forwarded-For headers
Posted: Wed Apr 27, 2016 2:43 pm
I run a mediawiki installation undera vestaCP and I need real ips to monitor contributions ip addresses, the problem is since I moved to a server with VestaCP all the contributions are listed under the same IP address which is the address of the server which I have tracked to be an issue related with nginx configuration and mediawiki supports that out of the box through this http://serverfault.com/questions/526547 ... 551#526551
The problem is that Im not very knowledgable in server stuff and I have been reading through nginx and vesta documentation and I haven't found the solution to nginx config
I have a SERVER_IP.conf which lists the following
I assume the problem is there and I want to be able to pass the real ip to media wiki through the X-Forwarded-For headers. How do I do that?
The problem is that Im not very knowledgable in server stuff and I have been reading through nginx and vesta documentation and I haven't found the solution to nginx config
I have a SERVER_IP.conf which lists the following
Code: Select all
server {
listen SERVER_IP:SERVER_PORT default;
server_name _;
#access_log /var/log/nginx/SERVER_IP.log main;
location / {
proxy_pass http://SERVER_IP:SERVER_PORT;
}
}
server {
listen 80;
server_name comp.tf;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:4567/;
proxy_redirect off;
# Socket.IO Support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}