nginx配置无法正常访问设置返回json数据

nginx配置无法正常访问设置返回json数据

经验文章nimo972025-06-07 17:09:553A+A-

将错误码单独添加到一个配置文件中

vi ./host/error.conf

proxy_intercept_errors on;
location error_page 502 {
      default_type application/json;
     return 500 '{"msg":"服务正在重启...","code": 500,"data":null}';
}

location error_page 504 {
     default_type application/json;
     return 500 '{"msg":"请求超时...","code": 500,"data":null}';
}


在nginx中引入error.conf

include ./host/error.conf


重启nginx:

systemctl restart nginx
点击这里复制本文地址 以上内容由nimo97整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!
qrcode

尼墨宝库 © All Rights Reserved.  蜀ICP备2024111239号-7