Heim  >  Fragen und Antworten  >  Hauptteil

vue.js – Problem mit der Nginx-Reverse-Proxy-Standortreihenfolge

Die folgenden Matching-Regeln sind mein Ziel

  1. Statische Bilder beginnen mit /api/img, Reverse-Proxy zu http://localhost:8084/, wie z. B. /api/img/default.png-Proxy zu http://localhost:8084/default...

  2. Statische Bilder beginnend mit /api/img/cdn/, Reverse-Proxy zu http://clouddn.com/ auf cdn, wie z. B. /api/img/cdn/default.png-Proxy zu http://clouddn.com / default.png

Der erste kann implementiert werden, der zweite jedoch nicht. Vielen Dank für Ihre Hilfe bei der Änderung
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;
    }
}
高洛峰高洛峰2713 Tage vor814

Antworte allen(2)Ich werde antworten

  • 我想大声告诉你

    我想大声告诉你2017-05-16 17:10:49

    把^~ /api/img/cdn/改成/api/img/cdn/呢,或者~ /api/img/cdn/,看一下location匹配规则,参考http://seanlook.com/2015/05/1...

    Antwort
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-16 17:10:49

    注意你路径中的斜杠,如果没有子目录把斜杠去了

    Antwort
    0
  • StornierenAntwort