問(wèn)題描述1.后臺(tái)使用X-Accel-Redirect來(lái)指定反向代理的網(wǎng)站: X-Accel-Redirect: /proxy/domain.com/path/to/index.php?id=1
或者
X-Accel-Redirect: /proxy/domain.com/path/to/index?id=12.nginx中l(wèi)ocation配置類(lèi)似如下來(lái)反向代理 location ~* ^/proxy/(.*?)/(.*){ set $proxy_host $1; set $proxy_uri $2; set $proxy_url http://$proxy_host/$proxy_uri$is_args$args;
proxy_pass $proxy_url;//想在這里原封不動(dòng)的把后臺(tái)傳遞的網(wǎng)址進(jìn)行代理
}對(duì)于第一個(gè)帶php后綴的代理,此location塊沒(méi)有被匹配到,頁(yè)面顯示404。而對(duì)于第二個(gè)沒(méi)帶php的,正常匹配到。因此猜測(cè)原因在于index.php中的點(diǎn)號(hào)(.)號(hào)無(wú)法被匹配到。環(huán)境背景及自己嘗試過(guò)哪些方法nginx/1.14.2嘗試的方法:參考匹配帶后綴的文件像location ~ \.php$我也試著這樣寫(xiě)location ~* ^/proxy/(.*?)/(.+\.php),但也無(wú)法被匹配的這星號(hào)應(yīng)該是匹配除換行符以外的所有字符,難以理解。在nginx文檔中看到The matching is performed against a normalized URI, after decoding the text encoded in the “%XX” form, resolving references to relative path components “.” and “..”, and possible compression of two or more adjacent slashes into a single slash.解析url中的".",".."?不知道是什么意思求大佬能夠指點(diǎn)一下,十分感謝。
1 回答

梵蒂岡之花
TA貢獻(xiàn)1900條經(jīng)驗(yàn) 獲得超5個(gè)贊
自己看了下locatio的正則匹配順序,猜測(cè)可能是因?yàn)榇藟K上面有匹配php后綴的location,于是這塊被忽略了。八成如此了,回去改改location的順序
- 1 回答
- 0 關(guān)注
- 962 瀏覽
添加回答
舉報(bào)
0/150
提交
取消