Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

Nginx - get real IP through X-Forwarded-For headers

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
3 posts • Page 1 of 1
spacing
Posts: 22
Joined: Thu Dec 03, 2015 9:44 pm

Nginx - get real IP through X-Forwarded-For headers
  • Quote

Post by spacing » 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

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";
    }
}
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?
Top

spacing
Posts: 22
Joined: Thu Dec 03, 2015 9:44 pm

Re: Nginx - get real IP through X-Forwarded-For headers
  • Quote

Post by spacing » Sat Apr 30, 2016 3:29 pm

any help?
Top

Falzo
Posts: 60
Joined: Mon Mar 28, 2016 8:49 am

Re: Nginx - get real IP through X-Forwarded-For headers
  • Quote

Post by Falzo » Mon May 02, 2016 7:11 pm

you're on the right track at least. every request made is received by nginx which serves as a reverse proxy in front of your apache installation.

easiest way to get rid of that problem would be to switch of proxy support for your affected domain within vesta.
depending on your needs you wouldn't benefit from fast loading static-files via nginx after that change...

if you prefer to run that proxied setup you should look into configuring the domain-related config file (probably the SERVER_IP.conf would help that much) to something like:

Code: Select all

    location / {
        proxy_set_header    Host			$host;
        proxy_set_header    X-Real-IP		$remote_addr;
        proxy_set_header    X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_pass  http://SERVER_IP:SERVER_PORT;
    }
be advised that vesta will overwrite changes to the domain-related files whenever something is changed on the domain-settings via controlpanel, so you probably need to make that changes in the template for the web-config you are running.
even adding this in the included file for custom changes won't work, as you can't define the /location block a second time.
Top


Post Reply
  • Print view

3 posts • Page 1 of 1

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

cron

Login  •  Register

I forgot my password