vue.js - nginx reverse proxy location order problem
高洛峰
高洛峰 2017-05-16 17:08:49
0
2
787

The following matching rules, my purpose is

  1. Static images starting with /api/img are reverse proxy to http://localhost:8084/, such as /api/img/default.png is proxy to http://localhost:8084/default. ..

  2. Static images starting with /api/img/cdn/, reverse proxy to http://clouddn.com/ on cdn, such as /api/img/cdn/default.png proxy to http:/ /clouddn.com/default.png

The first one can be implemented, but the second one cannot be implemented. Thank you for your help in modifying it
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;
    }
}
高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(2)
我想大声告诉你

Change ^~ /api/img/cdn/ to /api/img/cdn/, or ~ /api/img/cdn/, take a look at the location matching rules, refer to http://seanlook.com/2015/05 /1...

淡淡烟草味

Pay attention to the slashes in your path. If there are no subdirectories, remove the slashes

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!