Replace NGINX 403 for deny with a different error

2019-07-23 03:01发布

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.

2条回答
成全新的幸福
2楼-- · 2019-07-23 03:29

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

查看更多
beautiful°
3楼-- · 2019-07-23 03:46

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;
}
查看更多
登录 后发表回答