加入收藏 | 设为首页 | 会员中心 | 我要投稿 阜阳站长网 (https://www.0558zz.com/)- 科技、建站、内容创作、云计算、网络安全!
当前位置: 首页 > 运营中心 > Nginx > 正文

安全性 – 如何在nginx上拒绝使用404

发布时间:2020-07-16 10:49:50 所属栏目:Nginx 来源:互联网
导读:我想通过提供deny / allow指令来保护nginx中的某些位置,但我不希望局外人知道位置被拒绝.我希望局外人获得404,而不是403 http代码.我的配置代码段是location /admin/ { uwsgi_pass myupstream1; include /path/to/uwsgi_params; allow 12

我想通过提供deny / allow指令来保护nginx中的某些位置,但我不希望局外人知道位置被拒绝.我希望局外人获得404,而不是403 http代码.我的配置代码段是

location /admin/ {
    uwsgi_pass myupstream1;
    include /path/to/uwsgi_params;

    allow 127.0.0.1;
    deny all;
}

当我尝试访问/ admin / nginx使用HTTP 403响应时,但我希望它以HTTP 404响应.任何配方都可以吗? 最佳答案

error_page 403 404 /404.html;

location = /404.html {
    internal; #return 404
}

location /admin/ {
    uwsgi_pass myupstream1;
    include /path/to/uwsgi_params;

    allow 127.0.0.1;
    deny all;
}

The ‘internal’ returns 404 by default.

改编自这个答案here

(编辑:阜阳站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读