Code: Select all
wget -nv -O /usr/local/vesta/data/templates/web/nginx/forward.sh http://dl.myvestacp.com/vesta/vesta-cp-nginx-tpl/fwd-http2/forward.sh
wget -nv -O /usr/local/vesta/data/templates/web/nginx/forward.tpl http://dl.myvestacp.com/vesta/vesta-cp-nginx-tpl/fwd-http2/forward.tpl
wget -nv -O /usr/local/vesta/data/templates/web/nginx/forward.stpl http://dl.myvestacp.com/vesta/vesta-cp-nginx-tpl/fwd-http2/forward.stpl
chmod a+x /usr/local/vesta/data/templates/web/nginx/forward.sh
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-$domain.txt
/usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" 'forward' 'txt' 'yes'
In case you have custom enpoint port, do:
Code: Select all
user='your-vesta-user' # enter
domain='your-domain.com' # enter
newip='xxx.xxx.xxx.xxx' # enter
port='12345' # enter
echo "$newip:$port" > /home/$user/conf/web/forward-$domain.txt
/usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" 'forward' 'txt' 'yes'
Therefore, in case you have different enpoint port for HTTPS traffic, then we will create one additional file where we will separately define HTTPS port:
Code: Select all
user='your-vesta-user' # enter
domain='your-domain.com' # enter
newip='xxx.xxx.xxx.xxx' # enter
port='12345' # enter
porthttps='23456' # enter
echo "$newip:$port" > /home/$user/conf/web/forward-$domain.txt
echo "$newip:$porthttps" > /home/$user/conf/web/forward-$domain-https.txt
/usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" 'forward' 'txt' 'yes'
Sometimes you have only http endpoint (NodeJS app, for example), and you want both http and https:// interface to be proxied to http:// endpoint.
In that case do:
Code: Select all
user='your-vesta-user' # enter
domain='your-domain.com' # enter
newip='xxx.xxx.xxx.xxx' # enter
port='12345' # enter
echo "$newip:$port" > /home/$user/conf/web/forward-$domain.txt
echo "1" > /home/$user/conf/web/forward-$domain-only-http.txt
/usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" 'forward' 'txt' 'yes'
In case you want http visitor to redirect to https, then just copy force-https.tpl to forward.tpl:
Code: Select all
cp /usr/local/vesta/data/templates/web/nginx/force-https.tpl /usr/local/vesta/data/templates/web/nginx/forward.tpl
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