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 · Dec 10, 2019 · 5050 views
    This topic created in 2357 days ago, the information mentioned may be changed or developed.
    if ($request_method != GET) {                                  
        return 405;
    }
    

    例如

    2 replies    2019-12-10 23:20:58 +08:00
    sagaxu
        2
    sagaxu  
       Dec 10, 2019 via Android
    The only 100% safe things which may be done inside if in a location context are:

    return ...;
    rewrite ... last;
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5869 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 03:40 · PVG 11:40 · LAX 20:40 · JFK 23:40
    ♥ Do have faith in what you're doing.