Reverse proxy to antother IP

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

Post by dpeca »

You can install template that will do reverse proxy.

Code: Select all

wget -nv -O /usr/local/vesta/data/templates/web/nginx/
wget -nv -O /usr/local/vesta/data/templates/web/nginx/forward.tpl
wget -nv -O /usr/local/vesta/data/templates/web/nginx/forward.stpl
chmod a+x /usr/local/vesta/data/templates/web/nginx/
Now if you want to apply it to some domain:

Code: Select all

user='your-vesta-user' # enter
domain='' # enter
newip='' #  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.

If you want that all domains goes to the same IP, you can set it globaly instead of per account:

Code: Select all

echo "$newip" > /home/forward-all.txt
To apply it to all domains on server:

Code: Select all

    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
        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"
    service nginx reload


Post Reply