問題描述1.后臺使用X-Accel-Redirect來指定反向代理的網站: X-Accel-Redirect: /proxy/domain.com/path/to/index.php?id=1
或者
X-Accel-Redirect: /proxy/domain.com/path/to/index?id=12.nginx中location配置類似如下來反向代理 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;//想在這里原封不動的把后臺傳遞的網址進行代理
}對于第一個帶php后綴的代理,此location塊沒有被匹配到,頁面顯示404。而對于第二個沒帶php的,正常匹配到。因此猜測原因在于index.php中的點號(.)號無法被匹配到。環境背景及自己嘗試過哪些方法nginx/1.14.2嘗試的方法:參考匹配帶后綴的文件像location ~ \.php$我也試著這樣寫location ~* ^/proxy/(.*?)/(.+\.php),但也無法被匹配的這星號應該是匹配除換行符以外的所有字符,難以理解。在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中的".",".."?不知道是什么意思求大佬能夠指點一下,十分感謝。
1 回答

小怪獸愛吃肉
TA貢獻1852條經驗 獲得超1個贊
自己看了下locatio的正則匹配順序,猜測可能是因為此塊上面有匹配php后綴的location,于是這塊被忽略了。八成如此了,回去改改location的順序
- 1 回答
- 0 關注
- 489 瀏覽
添加回答
舉報
0/150
提交
取消