Reverse proxy to antother IP

Post Reply
User avatar
myVesta
Site Admin
Posts: 672
Joined: Fri Jun 19, 2020 9:59 am
Reverse proxy to antother IP

Post by myVesta »

You can install template that will do reverse proxy.

Code: Select all

wget -nv -O /usr/local/vesta/data/templates/web/nginx/forward.sh http://dl.mycity.tech/vesta/vesta-cp-nginx-tpl/fwd-http2/forward.sh
wget -nv -O /usr/local/vesta/data/templates/web/nginx/forward.tpl http://dl.mycity.tech/vesta/vesta-cp-nginx-tpl/fwd-http2/forward.tpl
wget -nv -O /usr/local/vesta/data/templates/web/nginx/forward.stpl http://dl.mycity.tech/vesta/vesta-cp-nginx-tpl/fwd-http2/forward.stpl
chmod a+x /usr/local/vesta/data/templates/web/nginx/forward.sh
If you want to apply it to some domain:

Code: Select all

user='your-vesta-user' # enter
domain='your-domain.com' # enter
newip='xxx.xxx.xxx.xxx' #  enter

echo "$newip" > /home/$user/conf/web/forward-all.txt
/usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" 'forward' 'txt' 'yes'
Last 'yes' is to restart nginx after each domain, so it can be 'no' and then restart manuly.


To apply redirection to all domains on ONE hosting account:

Code: Select all

user='your-vesta-user' # enter
newip='xxx.xxx.xxx.xxx' #  enter

echo "$newip" > /home/$user/conf/web/forward-all.txt

for domain in $(/usr/local/vesta/bin/v-list-web-domains $user plain |cut -f 1); do
    /usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" 'forward' 'txt' 'no'
    echo "=== Redirected: $domain"
done
service nginx reload

To apply redirection to all domains on the server:

Code: Select all

newip='xxx.xxx.xxx.xxx' #  enter

echo "$newip" > /home/forward-all.txt

for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
    if [ ! -f "/usr/local/vesta/data/users/$user/user.conf" ]; then
        continue;
    fi
    for domain in $(/usr/local/vesta/bin/v-list-web-domains $user plain |cut -f 1); do
        /usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" 'forward' 'txt' 'no'
        echo "=== Redirected: $domain"
    done
done
service nginx reload

Tags:

Meister
Posts: 24
Joined: Mon Nov 08, 2021 10:04 am
Re: Reverse proxy to antother IP

Post by Meister »

Hello,

I wanted to put a small vps server as a proxy in front of the domain to relieve the main server. Unfortunately the script does not redirect to my HestiaCP set up main server.

The vps was of course running myvestacp with Debian 11.
I first tested " To apply redirection to all domains on ONE hosting account: " and I saw myvestacp home. then I tested " To apply redirection to all domains on the server: " and the server did not go online after a reboot. is the script compatible with Debian 11?

User avatar
myVesta
Site Admin
Posts: 672
Joined: Fri Jun 19, 2020 9:59 am
Re: Reverse proxy to antother IP

Post by myVesta »

Meister wrote:
Fri Nov 19, 2021 12:11 pm
Hello,

I wanted to put a small vps server as a proxy in front of the domain to relieve the main server. Unfortunately the script does not redirect to my HestiaCP set up main server.

The vps was of course running myvestacp with Debian 11.
I first tested " To apply redirection to all domains on ONE hosting account: " and I saw myvestacp home. then I tested " To apply redirection to all domains on the server: " and the server did not go online after a reboot. is the script compatible with Debian 11?
Yes, it's compatible with Debian11.
You tested the script with myVesta?
What do you get when you type:

Code: Select all

systemctl status nginx

Meister
Posts: 24
Joined: Mon Nov 08, 2021 10:04 am
Re: Reverse proxy to antother IP

Post by Meister »

everything ok, it works perfectly now. it was a problem from the hoster :D .

Meister
Posts: 24
Joined: Mon Nov 08, 2021 10:04 am
Re: Reverse proxy to antother IP

Post by Meister »

Hello,

a question, is it intended that if you disable "Proxy supportNGINX" that it will still forward? Normally it should not forward then.

User avatar
myVesta
Site Admin
Posts: 672
Joined: Fri Jun 19, 2020 9:59 am
Re: Reverse proxy to antother IP

Post by myVesta »

Meister wrote:
Thu Nov 25, 2021 5:30 pm
Hello,

a question, is it intended that if you disable "Proxy supportNGINX" that it will still forward? Normally it should not forward then.
It will not forward then.


Post Reply