将NGINX 403替换为拒绝,并使用其他错误响应代码 [英] Replace NGINX 403 for deny with a different error response code

查看:261
本文介绍了将NGINX 403替换为拒绝,并使用其他错误响应代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我查看了文档,但是找不到用其他响应代码替换403的方法.我尝试使用error_page指令,它在配置检查时不会抱怨,但是它并不能有效地更改响应代码.

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.

推荐答案

我不确定您到底想要什么,但是如果您只想拒绝所有内容并显示不同的状态码(不是403),则可以使用例如,例如:(返回500)

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;
}

这篇关于将NGINX 403替换为拒绝,并使用其他错误响应代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆