We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
Original visitors IP X forwarded Headers
Original visitors IP X forwarded Headers
So I have a test page like this called test.php to show visitor's IP address. How ever it's showing server's internal IP.
<?php
echo $_SERVER['REMOTE_ADDR'];
?>
I tried to insert some values into local/ part of nginx.conf but did not work and didn't know where I am supposed to add it since there are few.
My question is a duplicate of this below I think.. but I can't understand how they fixed it. G.Translate is not helping
viewtopic.php?f=29&t=5106&p=12551&hilit=echo+$_SERVER['REMOTE_ADDR'];
Can you please tell me which one of these files I need to edit and add exactly what in there?
# sudo find / -name nginx.conf
/etc/nginx/nginx.conf
/usr/local/vesta/nginx/conf/nginx.conf
/usr/local/vesta/install/rhel/nginx.conf
/usr/local/vesta/install/rhel/monit/nginx.conf
/usr/local/vesta/install/debian/nginx.conf
/usr/local/vesta/install/ubuntu/nginx.conf
/usr/local/vesta/src/rpm/conf/nginx.conf
/home/admin/conf/web/nginx.conf
# sudo find / -name apache2.conf
/etc/apache2/apache2.conf
/usr/local/vesta/install/debian/apache2.conf
/usr/local/vesta/install/ubuntu/apache2.conf
/home/admin/conf/web/apache2.conf
I checked this http://vestacp.com/docs/#config-log-loc ... ian-ubuntu but it's kind of just showing me where all the files are.
I'd really appreciate that..
Thanks!
<?php
echo $_SERVER['REMOTE_ADDR'];
?>
I tried to insert some values into local/ part of nginx.conf but did not work and didn't know where I am supposed to add it since there are few.
My question is a duplicate of this below I think.. but I can't understand how they fixed it. G.Translate is not helping
viewtopic.php?f=29&t=5106&p=12551&hilit=echo+$_SERVER['REMOTE_ADDR'];
Can you please tell me which one of these files I need to edit and add exactly what in there?
# sudo find / -name nginx.conf
/etc/nginx/nginx.conf
/usr/local/vesta/nginx/conf/nginx.conf
/usr/local/vesta/install/rhel/nginx.conf
/usr/local/vesta/install/rhel/monit/nginx.conf
/usr/local/vesta/install/debian/nginx.conf
/usr/local/vesta/install/ubuntu/nginx.conf
/usr/local/vesta/src/rpm/conf/nginx.conf
/home/admin/conf/web/nginx.conf
# sudo find / -name apache2.conf
/etc/apache2/apache2.conf
/usr/local/vesta/install/debian/apache2.conf
/usr/local/vesta/install/ubuntu/apache2.conf
/home/admin/conf/web/apache2.conf
I checked this http://vestacp.com/docs/#config-log-loc ... ian-ubuntu but it's kind of just showing me where all the files are.
I'd really appreciate that..
Thanks!
Re: Original visitors IP X forwarded Headers
Maybe this might help https://rtcamp.com/tutorials/nginx/forw ... s-real-ip/RouterRat wrote:So I have a test page like this called test.php to show visitor's IP address. How ever it's showing server's internal IP.
<?php
echo $_SERVER['REMOTE_ADDR'];
?>
I tried to insert some values into local/ part of nginx.conf but did not work and didn't know where I am supposed to add it since there are few.
My question is a duplicate of this below I think.. but I can't understand how they fixed it. G.Translate is not helping
viewtopic.php?f=29&t=5106&p=12551&hilit=echo+$_SERVER['REMOTE_ADDR'];
Can you please tell me which one of these files I need to edit and add exactly what in there?
# sudo find / -name nginx.conf
/etc/nginx/nginx.conf
/usr/local/vesta/nginx/conf/nginx.conf
/usr/local/vesta/install/rhel/nginx.conf
/usr/local/vesta/install/rhel/monit/nginx.conf
/usr/local/vesta/install/debian/nginx.conf
/usr/local/vesta/install/ubuntu/nginx.conf
/usr/local/vesta/src/rpm/conf/nginx.conf
/home/admin/conf/web/nginx.conf
# sudo find / -name apache2.conf
/etc/apache2/apache2.conf
/usr/local/vesta/install/debian/apache2.conf
/usr/local/vesta/install/ubuntu/apache2.conf
/home/admin/conf/web/apache2.conf
I checked this http://vestacp.com/docs/#config-log-loc ... ian-ubuntu but it's kind of just showing me where all the files are.
I'd really appreciate that..
Thanks!
Re: Original visitors IP X forwarded Headers
Hey thanks for the reply!
I actually gave this a try but here is where I am lost there are 3 recommendations here which I only tried 2nd.
1st change
2nd change
3rd change
So which one am I supposed to do and in which nginx file?
# sudo find / -name nginx.conf
/etc/nginx/nginx.conf
/usr/local/vesta/nginx/conf/nginx.conf
/usr/local/vesta/install/rhel/nginx.conf
/usr/local/vesta/install/rhel/monit/nginx.conf
/usr/local/vesta/install/debian/nginx.conf
/usr/local/vesta/install/ubuntu/nginx.conf
/usr/local/vesta/src/rpm/conf/nginx.conf
/home/admin/conf/web/nginx.conf
Thanks!
I actually gave this a try but here is where I am lost there are 3 recommendations here which I only tried 2nd.
1st change
Code: Select all
Nginx config from front-end proxy
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Code: Select all
following lines inside backend-nginx conf:
location ~ \.php$ {
fastcgi_param REMOTE_ADDR $http_x_real_ip;
#...other rules
}
Code: Select all
by adding a line like below to your backend nginx-config:
set_real_ip_from 192.168.122.1;
# sudo find / -name nginx.conf
/etc/nginx/nginx.conf
/usr/local/vesta/nginx/conf/nginx.conf
/usr/local/vesta/install/rhel/nginx.conf
/usr/local/vesta/install/rhel/monit/nginx.conf
/usr/local/vesta/install/debian/nginx.conf
/usr/local/vesta/install/ubuntu/nginx.conf
/usr/local/vesta/src/rpm/conf/nginx.conf
/home/admin/conf/web/nginx.conf
Thanks!
Re: Original visitors IP X forwarded Headers
Dependings on the nginx template you use for each client you find them underRouterRat wrote:Hey thanks for the reply!
I actually gave this a try but here is where I am lost there are 3 recommendations here which I only tried 2nd.
1st change
2nd changeCode: Select all
Nginx config from front-end proxy proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
3rd changeCode: Select all
following lines inside backend-nginx conf: location ~ \.php$ { fastcgi_param REMOTE_ADDR $http_x_real_ip; #...other rules }
So which one am I supposed to do and in which nginx file?Code: Select all
by adding a line like below to your backend nginx-config: set_real_ip_from 192.168.122.1;
# sudo find / -name nginx.conf
/etc/nginx/nginx.conf
/usr/local/vesta/nginx/conf/nginx.conf
/usr/local/vesta/install/rhel/nginx.conf
/usr/local/vesta/install/rhel/monit/nginx.conf
/usr/local/vesta/install/debian/nginx.conf
/usr/local/vesta/install/ubuntu/nginx.conf
/usr/local/vesta/src/rpm/conf/nginx.conf
/home/admin/conf/web/nginx.conf
Thanks!
/usr/local/vesta/data/templates/web/nginx
Re: Original visitors IP X forwarded Headers
So I left everything on default. It's fresh out of the box..
First I need to find if I am using "front-end proxy" or "backend-nginx conf" correct?
After that if I am using front-end proxy I have to add
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
and if I am using back-end nginx conf I need to add a rule like this
location ~ \.php$ {
fastcgi_param REMOTE_ADDR $http_x_real_ip;
#...other rules
}
Do I still need to do this in back end nginx config?
set_real_ip_from 192.168.122.1; -- my local ip
Are these correct statemets?
First I need to find if I am using "front-end proxy" or "backend-nginx conf" correct?
After that if I am using front-end proxy I have to add
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
and if I am using back-end nginx conf I need to add a rule like this
location ~ \.php$ {
fastcgi_param REMOTE_ADDR $http_x_real_ip;
#...other rules
}
Do I still need to do this in back end nginx config?
set_real_ip_from 192.168.122.1; -- my local ip
Are these correct statemets?
Re: Original visitors IP X forwarded Headers
So can you tell me if I have a www.example.com
Where is front-end nginx config and where is back-end nginx config for this domain on default settings for VestaCP?
Where is front-end nginx config and where is back-end nginx config for this domain on default settings for VestaCP?
Re: Original visitors IP X forwarded Headers
So my client is using the "default"
I changed both /usr/local/vesta/data/templates/web/nginx/default.tpl and default.stpl
To this, does it look correct?
If this looks correct where is the other file where I have to put down the IP?
I changed both /usr/local/vesta/data/templates/web/nginx/default.tpl and default.stpl
To this, does it look correct?
If this looks correct where is the other file where I have to put down the IP?
Code: Select all
server {
listen %ip%:%proxy_port%;
server_name %domain_idn% %alias_idn%;
error_log /var/log/%web_system%/domains/%domain%.error.log error;
location / {
proxy_pass http://%ip%:%web_port%;
location ~* ^.+\.(%proxy_extentions%)$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
root %docroot%;
access_log /var/log/%web_system%/domains/%domain%.log combined;
access_log /var/log/%web_system%/domains/%domain%.bytes bytes;
expires max;
try_files $uri @fallback;
}
}
location /error/ {
alias %home%/%user%/web/%domain%/document_errors/;
}
location @fallback {
proxy_pass http://%ip%:%web_port%;
}
location ~ /\.ht {return 404;}
location ~ /\.svn/ {return 404;}
location ~ /\.git/ {return 404;}
location ~ /\.hg/ {return 404;}
location ~ /\.bzr/ {return 404;}
include %home%/%user%/conf/web/nginx.%domain%.conf*;
}
Re: Original visitors IP X forwarded Headers
For the above code I would putRouterRat wrote:So my client is using the "default"
I changed both /usr/local/vesta/data/templates/web/nginx/default.tpl and default.stpl
To this, does it look correct?
If this looks correct where is the other file where I have to put down the IP?
Code: Select all
server { listen %ip%:%proxy_port%; server_name %domain_idn% %alias_idn%; error_log /var/log/%web_system%/domains/%domain%.error.log error; location / { proxy_pass http://%ip%:%web_port%; location ~* ^.+\.(%proxy_extentions%)$ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; root %docroot%; access_log /var/log/%web_system%/domains/%domain%.log combined; access_log /var/log/%web_system%/domains/%domain%.bytes bytes; expires max; try_files $uri @fallback; } } location /error/ { alias %home%/%user%/web/%domain%/document_errors/; } location @fallback { proxy_pass http://%ip%:%web_port%; } location ~ /\.ht {return 404;} location ~ /\.svn/ {return 404;} location ~ /\.git/ {return 404;} location ~ /\.hg/ {return 404;} location ~ /\.bzr/ {return 404;} include %home%/%user%/conf/web/nginx.%domain%.conf*; }
belowproxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Placelocation / {
proxy_pass http://%ip%:%web_port%;
Code: Select all
set_real_ip_from
Re: Original visitors IP X forwarded Headers
Hey thank you for the answer I just did the changes I have few other questions though.
It's OK for me to change default.tpl and default.stpl since it will not make that much of a difference.
Also my server has two private IP that are not public IPs I do nat, what IP will be used here the local IP which is what's assigned to the site or a public IP?
It's OK for me to change default.tpl and default.stpl since it will not make that much of a difference.
How do toggle all users and rebuild web?you need to toggle all users and rebuild web.
Also my server has two private IP that are not public IPs I do nat, what IP will be used here the local IP which is what's assigned to the site or a public IP?
set_real_ip_from
Re: Original visitors IP X forwarded Headers
Login Vesta CP -> Click Users Tab -> Next to add user is "Toggle All Users" click it -> Next to that is a drop down menu -> Select rebuild web -> click the little button next to that.RouterRat wrote:How do toggle all users and rebuild web?
RouterRat wrote:Also my server has two private IP that are not public IPs I do nat, what IP will be used here the local IP which is what's assigned to the site or a public IP?
I really would need to see a phpinfo page to answer that. But my best guess would be use the public IP or you could add all the ips and remove them one by one to see which ones work.