事情是這樣的,本人待的小公司因為沒有 load balance 的機制(成本考量),因此在 Server 重新 build 的時候網站會呈現掛點狀態(?不意外吧),為了解決這樣的問題,所以決定要做一個 error page 去告訴敷衍使用者 :)

需求: 當伺服器改版或錯誤時,需要做一個頁面讓使用者知道我們的服務沒有問題

nginx 設定如下

        # 升級頁面
        proxy_intercept_errors on;
        error_page   500 502 503 504  /index.html;
        location = /index.html {
            root /home/ubuntu/www/;
        }
        location ~ \.(mp3|mp4) {
                root /home/ubuntu/www/media/;
        }

接著把靜態頁面放進去www資料夾裡面,搞定!