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

used vesta before hestia, in vesta all good
hestia is installed with apache+nginx.
tried your config in post above, nothing works.
i mean, i see only IP of my front-end proxy
and no real IP

looks like i get it done
just commented
#proxy_set_header X-Real-IP $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
in hestia nginx.conf
now it looks good

just one question
why, i mean srsly, WHY on vesta, SAME config but it works, but why on hestia such prolems ?
i didn’t comment
#proxy_set_header X-Real-IP $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
this on vesta, but it’s present there too, BUT, no problems at all
WHY on hestia it’s doesn’t work ?

Checked it on 2 different servers both Hestia

# Proxy settings
proxy_redirect                  off;
proxy_set_header                Host $host;
proxy_set_header                X-Real-IP $remote_addr;
proxy_set_header                X-Forwarded-For $proxy_add_x_forwarded_for;

No issues over here maybe check error logs / systemctl status nginx what the cause of it it…

Do you have multiple IPs on the destination server? If I remember right there was something in apache2 to enable or adjust, so it receives the headers correctly.
I can look it up tomorrow right now I am only on mobile and it’s late here…

I just checked. please make sure mod_remoteip is enabled with apache2 (should be by default) and if /etc/apache2/mods-enabled/remoteip.conf has all of your IPs in it. If I remember correctly I hab a problem there with a multi IP server back in the days.

I am also not sure how nginx in the middle passes on the already set x-forwarded-for header, so could be that you should adjust the IP from the sending server in that remoteip conf to the one from your frontend-proxy instead of the local one…

simple: Hestia is not Vesta and we changed quite some things for a lot of different reasons. and we cannot and will not guarantue backwards compatibility in all regards. so, sorry to say, but feel free to stick with Vesta, otherwise you might need to invest a bit time and work to find the right configuration for you :wink: