vue.js - nginx反向代理location順序問題
問題描述
以下匹配規則,我的目的是
以/api/img 開頭的靜態圖片,反向代理到http://localhost:8084/,如/api/img/default.png代理到http://localhost:8084/default...
以/api/img/cdn/ 開頭的靜態圖片,反向代理到cdn上http://clouddn.com/,如/api/img/cdn/default.png代理到http://clouddn.com/default.png
第一條可以實現,第二條無法實現,謝謝幫忙修改server {
listen 8085; server_namelocalhost; location /api/v1 { proxy_pass http://localhost:8084/api/v1; } location ^~ /api/img/cdn/ { proxy_pass http://clouddn.com/; } location /api/img { proxy_pass http://localhost:8084/; } location / {root html/vue2;index index.html index.htm; }}
問題解答
回答1:把^~ /api/img/cdn/改成/api/img/cdn/呢,或者~ /api/img/cdn/,看一下location匹配規則,參考http://seanlook.com/2015/05/1...
回答2:注意你路徑中的斜杠,如果沒有子目錄把斜杠去了
相關文章:
