nginx配置无法正常访问设置返回json数据
将错误码单独添加到一个配置文件中
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