国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

web - nginx location 搜尋演算法問題! ?
黃舟
黃舟 2017-05-16 17:27:37
0
1
1143

先貼出我的server設(shè)定:

server {
    listen 80;
    server_name xxx; 
    # 1
    location = /favicon.ico {
        root /home/www-data/static;
        rewrite (.*) /img/designs/admin-favicon.ico;
    }
    #2
    location = /robots.txt {
        root /home/www-data/static;
        rewrite (.*) /admin-robots.txt;
    }
    # 3
    location / {
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_pass http://127.0.0.1:22222;
     }
}

官方給出的location搜尋路徑優(yōu)先權(quán)和演算法描述如下:

To find location matching a given request, nginx first checks
locations defined using the prefix strings (prefix locations). Among
them, the location with the longest matching prefix is selected and
remembered. Then regular expressions are checked, in the order of
their appearance in the configuration file. The search of regular
expressions terminates on the first match, and the corresponding
configuration is used. If no match with a regular expression is found
then the configuration of the prefix location remembered earlier is
used.

依照我的理解,Nginx搜尋的時(shí)候演算法應(yīng)該是這樣的:

  1. 按照請(qǐng)求前綴搜尋location最長(zhǎng)普通前綴匹配(如果有=修飾符,則直接匹配該location,如果有^~修飾符,則直接使用該location),記住最長(zhǎng)匹配location。
  2. 繼續(xù)按照配置順序搜尋正規(guī)匹配,如果有,則直接匹配第一個(gè)匹配到的location,否則使用普通最長(zhǎng)location

也就說,按照我的配置,瀏覽器請(qǐng)求/favicon.ico的時(shí)候,應(yīng)該是直接精準(zhǔn)匹配到
1 才對(duì)啊,可是每次都配對(duì)到 3。

這裡請(qǐng)教各位,我對(duì)Nginx location的理解有沒有偏差?然後為什麼我的配置會(huì)是這樣的結(jié)果?

黃舟
黃舟

人生最曼妙的風(fēng)景,竟是內(nèi)心的淡定與從容!

全部回覆(1)
給我你的懷抱

按照樓主的方法配置了一下,我這裡是可以進(jìn)到# 1的。
我覺得可能是CDN快取的問題。樓主試試別的檔案rewrite或是在沒有CDN的環(huán)境下試試。

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板