概述
1. 自己写了一个error.html页面
2. 更改nginx.conf在http定义区域加入: fastcgi_intercept_errors on;
3. 更改nginx.conf中在server 区域加入: error_page 404 /404.html
4. 重启ngnix
另外,有一个8000端口的错误页面也要跳转到80的error页面,
在server 8000下添加 error_page 404 error, 另外 include error.conf
# the difference when adding URI to proxy_pass directive:
# http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass
# why I use variable but not staticlly config the url:
# http://forum.nginx.org/read.php?2,215830,215832#msg-215832
#
# and resolver is needed, or will get 502, ref:
# https://stackoverflow.com/questions/5743609/
#
# why use rewrite: http://wiki.nginx.org/HttpProxyModule#proxy_pass
resolver 127.0.0.1;
location /error {
proxy_pass http://127.0.0.1:80;
}
location /images {
proxy_pass http://127.0.0.1:80;
}
location /js {
proxy_pass http://127.0.0.1:80;
}
location /css {
proxy_pass http://127.0.0.1:80;
}
最后
以上就是精明夕阳为你收集整理的nginx 404 跳转到自定义的页面的全部内容,希望文章能够帮你解决nginx 404 跳转到自定义的页面所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复