• nginx自定义404页面


    主要是记录踩过的一个坑。。。

    nginx要自定义404和500的页面,但是error_page 配置没有生效,没有正常跳转。

    error_page  404  /404.html;
    error_page  500 503 502  /500.html;
    location = /500.html {    
                root html;
            }
    location = /404.html {
                root html;
            }

    这是因为我们的静态资源在上游服务器上,而不是当前nginx直接提供。

    nginx proxy 启用自定义错误页面:

    语法:proxy_intercept_errors on | off;

    默认值:

    proxy_intercept_errors off;

    上下文:http, server, location

    当被代理的后端服务器的响应状态码大于等于300时,决定是否直接将响应发送给客户端,亦或将响应转发给nginx由error_page指令来处理。

     proxy_intercept_errors 为on 表示 nginx按照原response code 输出,后端是404就是404。这个变量开启后,我们才能自定义错误页面。

    proxy_intercept_errors on;

    修改后测试通过

  • 相关阅读:
    实验6.1
    SOA
    python的镜像包安装
    中文分词:双向匹配最大算法(BI-MM)
    从github中获取代码
    解决文件冲突
    创建分支
    上传本地文件到github
    mysql事务
    查询练习2
  • 原文地址:https://www.cnblogs.com/xulan0922/p/9224260.html
Copyright © 2020-2023  润新知