以下匹配规则,我的目的是
以/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_name localhost;
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;
}
}
我想大声告诉你2017-05-16 17:10:49
把^~ /api/img/cdn/改成/api/img/cdn/呢,或者~ /api/img/cdn/,看一下location匹配规则,参考http://seanlook.com/2015/05/1...