gpt4 book ai didi

Nginx 位置优先级

转载 作者:行者123 更新时间:2023-12-04 22:43:22 25 4
gpt4 key购买 nike

位置指令按什么顺序触发?

最佳答案

来自 HTTP core module docs :

  • 带有“=”前缀的指令与查询完全匹配。如果找到,则停止搜索。
  • 所有剩余的带有常规字符串的指令。如果此匹配使用了“^~”前缀,则搜索停止。
  • 正则表达式,按照它们在配置文件中定义的顺序。
  • 如果 #3 产生匹配,则使用该结果。否则,使用来自#2 的匹配。

  • 文档中的示例:
    location  = / {
    # matches the query / only.
    [ configuration A ]
    }
    location / {
    # matches any query, since all queries begin with /, but regular
    # expressions and any longer conventional blocks will be
    # matched first.
    [ configuration B ]
    }
    location /documents/ {
    # matches any query beginning with /documents/ and continues searching,
    # so regular expressions will be checked. This will be matched only if
    # regular expressions don't find a match.
    [ configuration C ]
    }
    location ^~ /images/ {
    # matches any query beginning with /images/ and halts searching,
    # so regular expressions will not be checked.
    [ configuration D ]
    }
    location ~* \.(gif|jpg|jpeg)$ {
    # matches any request ending in gif, jpg, or jpeg. However, all
    # requests to the /images/ directory will be handled by
    # Configuration D.
    [ configuration E ]
    }

    如果仍然令人困惑, here's a longer explanation .

    关于Nginx 位置优先级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61597048/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com