V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
xx3122
V2EX  ›  NGINX

nginx 大佬过来看看怎么弄?

  •  
  •   xx3122 · 2022-09-01 18:20:37 +08:00 · 1585 次点击
    这是一个创建于 593 天前的主题,其中的信息可能已经有所发展或是发生改变。

    1.想要的效果是 nginx 日志记录出状态为 403 ,但浏览器看状态为 200 ,该怎么配置,我以前配置成功了的但是忘了

    error_page 403 503 =200 @403;
    location @403 { default_type application/json;
    return 200 '{"code":"403", "message": "请使用高级浏览器访问本站比如 Chrome 、火狐等访问,谢谢!"}';
    break;
    }
    location /ip {
    add_header Content-Type text/html;
    return 403;
    }

    日志:"GET /ip?dfs=dasd&sd=112 HTTP/1.1" 403

    xx3122
        1
    xx3122  
    OP
       2022-09-01 18:41:10 +08:00
    另外 add_header 、more_set_headers 、default_type 有啥区别啊
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1072 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 18:51 · PVG 02:51 · LAX 11:51 · JFK 14:51
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.