Unlike a firewall port forward which does a whole server, this tip only works on a virtual host by virtual host bases.
When you change the nameservers or update the A record some ISP’s will ignore your TTL and cache the old DNS for 12, 24 or even longer in some extreme cases meaning the new server is not visible.
Here is a quick tip to get your site working on the new server immediately using the nginx forward proxy feature.
In plesk go to /etc/nginx/plesk.conf.d/vhosts/
Then edit the relevant host file.
You are looking for the section that starts with
location / {
You are looking for the line containing proxy_pass for example (IP Address x’d out.)
proxy_pass https://xxx.xxx.xxx.xxx:7081;
What this does is forward your vhost to port 7081 on the same server running apache2.
You need to change this to the IP address of your new server and port 443 (normal ssl).
proxy_pass https://zzz.zzz.zzz.zzz:443;
Now repeat this process for the sections that start with.
location @fallback {
and
location ~ ^/~(.+?)(/.*)?$ {
Now comment out the php section (this will allow ajax functions to work again). To do this put a # at the start of each line so it looks like this.
# location ~ \.php(/.*)?$ { # fastcgi_read_timeout 300; # fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; # try_files $uri $fastcgi_script_name =404; # fastcgi_param PATH_INFO $fastcgi_path_info; # fastcgi_pass "unix:/var/www/vhosts/system/your-domain.com/php-fpm.sock"; # include /etc/nginx/fastcgi.conf; # }
Now restart the nginx server.
service nginx restart
PLEASE NOTE: If you do anything in plesk this may rewrite the configuration and undo the forward. You can either be careful or go to the directory with the actual file in it.
/var/www/vhosts/system/my-domain.com/conf/
and run this command
chattr +i nginx.conf
This will make the file immutable and even root user programs cannot alter it without turning off the immutable bit. Plesk may throw a wobbly at this but your file will not be changed.
Details:
Last tested on. Centos 7, Plesk Obsidian 18.0.60.1 and nginx 1.24.
Leave a Reply