Heim  >  Fragen und Antworten  >  Hauptteil

Problem mit der Konfiguration regulärer Ausdrücke des Nginx-Reverse-Proxys

Meine Nginx-Reverse-Proxy-Konfiguration ist wie folgt:

location ^~ /a(pi|uth) {
    proxy_pass http://localhost:3000;

    # Proxy Settings
    proxy_set_header    HOST    $host;
    proxy_set_header    X-Real-IP   $remote_addr;
    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
    ...
}

Ich hoffe, dass alle Anfragen /api/*/auth/* an Port 3000 gesendet werden, aber der Abgleich scheint meiner Meinung nach kein Problem mit dem regulären Ausdruck zu sein

javascript/a(pi|uth)/.test('api') // true

Ich kann es direkt zuordnenlocation ^~ /api, aber es funktioniert nicht, wenn ich reguläre Ausdrücke verwende. Ich weiß nicht, was los ist

伊谢尔伦伊谢尔伦2713 Tage vor487

Antworte allen(1)Ich werde antworten

  • PHPz

    PHPz2017-05-16 17:25:02

    location ~* /a(pi|uth)
    

    看了下好像^~不匹配正则吧

    Antwort
    0
  • StornierenAntwort