NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
zhaoyc2018
V2EX  ›  NGINX

请教一下,为什么 nginx 的 try_files 在使用 if 过后无效?

  •  
  •   zhaoyc2018 · Apr 1, 2019 · 3801 views
    This topic created in 2590 days ago, the information mentioned may be changed or developed.
    location ~ "/test-p15990\.html$" {
    if ( $whitelist = 0 ) {
    set $test 1;
    }

    default_type "text/html; charset=UTF-8";

    add_header debug "test1";

    try_files /html/p15/990 =404;
    }

    注销第 2 和第 4 行就正常返回页面,说明设置变量没有问题,如果$whitelist 为 1 时是正常的。

    但问题是当$whitelist 为 0 时就不行了呢?
    5 replies    2019-04-01 13:22:59 +08:00
    uncat
        1
    uncat  
       Apr 1, 2019 via iPhone
    优先级问题,后者高
    zhaoyc2018
        2
    zhaoyc2018  
    OP
       Apr 1, 2019
    优先级?没搞懂 @uncat
    mcfog
        3
    mcfog  
       Apr 1, 2019
    no1xsyzy
        4
    no1xsyzy  
       Apr 1, 2019
    我猜应该是 try_files 没有被 if 配置块继承。
    zhaoyc2018
        5
    zhaoyc2018  
    OP
       Apr 1, 2019
    add_header 也没有用,看来就是 @mcfog 所说的问题。。。

    谢谢各位
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2806 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 55ms · UTC 14:17 · PVG 22:17 · LAX 07:17 · JFK 10:17
    ♥ Do have faith in what you're doing.