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

Nginx 不建议使用 if 的话, 还能怎样控制只允许 GET 请求

  •  
  •   aoscici2000 · 2019-12-10 21:00:44 +08:00 · 3937 次点击
    这是一个创建于 1571 天前的主题,其中的信息可能已经有所发展或是发生改变。
    if ($request_method != GET) {                                  
        return 405;
    }
    

    例如

    2 条回复    2019-12-10 23:20:58 +08:00
    gstqc
        1
    gstqc  
       2019-12-10 21:04:31 +08:00 via Android   ❤️ 3
    sagaxu
        2
    sagaxu  
       2019-12-10 23:20:58 +08:00 via Android
    The only 100% safe things which may be done inside if in a location context are:

    return ...;
    rewrite ... last;
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2894 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 14:18 · PVG 22:18 · LAX 07:18 · JFK 10:18
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.