網站升級需要停服,可以在Nginx設置靜態頁面設置強制跳轉
修改nginx配置文件nginx.conf
http {
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.example.com;
#rewrite ^(.*)$ /pages/index.html break;
location ~* ^.+\.(jpg|jpeg|gif|png|bmp)$ {
access_log off;
root /opt/nginx/html;
expires 30d;
break;
}
location / {
root /opt/nginx/html;
rewrite ^(.*)$ /pages/index.html break;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
說明:
1,站點根目錄是/opt/nginx/html
2,在跟目錄新建維護站點目錄pages
3,目錄文件夾結構如下(需要把img在站點跟目錄放置一份否則不顯示圖片)

4,需要設置兩個rewrite第一個遇到圖片不強制跳轉(如不設置將不顯示圖片因為圖片作為一個鏈接會強制跳轉)
