歡迎您光臨本站 註冊首頁

nginx如何在使用proxy_pass以後依然能使用error_page?

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

nginx如何在使用proxy_pass以後依然能使用error_page?

server {
        listen 80;
        server_name cz.test.com;
        access_log /var/log/nginx/cz.test.com.access.log;
        root /tmp/cz;
        location / {
                include /etc/nginx/proxy.conf;
                                error_page 404 = /about.html;
                                recursive_error_pages on;
                                if (-f $request_filename/index.html) {
                                    rewrite (.*) $1/index.html break;
                                }
                                if (-f $request_filename.html) {
                                   rewrite (.*) $1.html break;
                               }
                               if (!-f $request_filename) {
                                   proxy_pass http://172.20.2.160;
                                   break;
                               }
        }
}

如果沒有proxy_pass肯定是沒有問題的。怎麼才能在使用proxy_pass之後error_page也管用呢,有沒有大俠有過這個經驗。

我主要想轉一下維護頁面,先拿404頁面測試一下。
《解決方案》

是不是因為設置了:recursive_error_pages on;
《解決方案》

你的問題解決了嗎?解決的話,寫下解決方法吧?遇到同樣的問題 :D
《解決方案》

LZ可以試試設置一下 proxy_intercept_errors on;
這個要在1.1.x以上版本可以使用。


lafang2009 發表於 2011-01-24 11:54 static/image/common/back.gif
server {
        listen 80;
        server_name cz.test.com;
《解決方案》

tjpm 發表於 2012-04-28 18:28 static/image/common/back.gif
LZ可以試試設置一下 proxy_intercept_errors on;
這個要在1.1.x以上版本可以使用。


有嘗試了,沒用。測試的版本是nginx-1.2.0

[火星人 ] nginx如何在使用proxy_pass以後依然能使用error_page?已經有855次圍觀

http://coctec.com/docs/service/show-post-12304.html