nginx post/get请求全部访问制定页面

 

不要修改Content-Type

error_page 405 =200 @405;
location @405 {
root /usr/share/nginx/html;
proxy_method GET;
proxy_pass http://127.0.0.1/$request_uri;
}
location / {
rewrite ^(.*)$ /index.html break;
}

 

 

需要修改Content-Type

error_page 405 =200 @405;
location @405 {
root /usr/share/nginx/html;
proxy_method GET;
proxy_pass http://127.0.0.1/$request_uri;
}
location / {

default_type application/json;
return 200 '{"result": "","code": 302, "message": "Request failed. Please try again later (Error code:500).","msgDetails": "服务升级中,请稍后再试"}';

}

posted @ 2021-07-15 15:04  David---wei  阅读(292)  评论(0编辑  收藏  举报