HTTP_X_FORWARDED_FOR and nginx frontend server problems

TL;DR
i can’t get real visitor ip in hestia, in vesta all good.
I CAN PAY IN BITCOINS FOR SOLUTION AND I NEED IT ASAP


switched from vesta, all good but one thing.
i use separated nginx frontend proxy, and all i need that HTTP_X_FORWARDED_FOR header gets the real visitor IP. but i have it in this way 127.0.0.1, 127.0.0.2 (just example)
first one 127.0.0.1 it’s real visitor ip, all good but i get also 127.0.0.2 and here goes my nginx proxy ip

in vesta no such problem, please help me fix it.

i use this nginx config for my frontend proxy (separated vps, no panel there)

server {
listen 80;
server_name domain.com;

    location / {
    proxy_pass_header Server;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_pass http://127.0.0.1; <<<HERE IS REAL IP OF MY SERVER WITH HESTIA
    }
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /usr/share/nginx/html;
    }
    }

always used this config, with any panel, even with cPanels on shared hostings. but can’t get it done with hestia. sites working, but header x_forwarded_for in <?php phpinfo(); ?> page shows like
$_SERVER[‘HTTP_X_FORWARDED_FOR’] REAL IP HERE, NGINX FRONTEND IP HERE
so it’s doubled, but i need only real ip of the visitor.

First of all welcome.
2nd what is your server server setup

Apache, Nginx?

Incase Nginx is used as proxy server on the new Hestia server

# Proxy settings
proxy_redirect                  off;
proxy_set_header                Host $host;
proxy_set_header                X-Real-IP  $proxy_add_x_forwarded_for;
proxy_set_header                X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_header               Set-Cookie;
proxy_buffers                   32 4k;
proxy_connect_timeout           30s;
proxy_read_timeout              300s;
proxy_send_timeout              180s;

In nginx.conf and it should work

2 Likes