Replace NGINX 403 for deny with a different error response code

房东的猫 提交于 2020-01-06 02:29:09

问题


location ~* ^/(jmx-cons|web-console|debug|invoker)/ {
deny all;
}

I have looked over the documentation but I cannot find a way to replace the 403 with a different response code. I have tried using the error_page directive and it doesn't complain on config check but it doesn't effectively change the response code.


回答1:


Turns out that the error_page directive does work for this purpose, I was just doing it wrong. :)




回答2:


I'm not sure what you exactly want, but if all you want is denying all and showing a different status code ( not 403 ) you can use return instead, for example: ( returning 500 )

location ~* ^/(jmx-cons|web-console|debug|invoker)/ {
    return 500;
}


来源:https://stackoverflow.com/questions/18751032/replace-nginx-403-for-deny-with-a-different-error-response-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!