Heim  >  Fragen und Antworten  >  Hauptteil

Nginx-Reverse-Proxy-Konfiguration für den Zugriff auf das Backend, grundlegende Fragen?

Der Screenshot des Fehlerberichts lautet wie folgt:

XMLHttpRequest cannot load http://localhost:9090/services/user/login. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access. The response had HTTP status code 403.

Die Reverse-Proxy-Konfiguration ist wie folgt:

Entschuldigung, was ist das Problem mit der Konfiguration?

大家讲道理大家讲道理2714 Tage vor513

Antworte allen(4)Ich werde antworten

  • 伊谢尔伦

    伊谢尔伦2017-05-16 17:12:12

    是跨域问题吧,参见/a/11...

    Antwort
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-16 17:12:12

    server_name 用 localhost 就好,不必带端口,不然 http://localhost:9090/services/ 就转发到 9000 端口了。配置其他部分应该没毛病,提一点建议,nginx配置也贴代码而不是图片就好了,谢谢。

    server {
        listen       9090;
        server_name  localhost; // 修改这里
        
        location /front/ {
            proxy_pass http://127.0.0.1:9000/;
        }
        
        location /services/ {
            proxy_pass http://127.0.0.1:8080/services/;
        }
    }

    Antwort
    0
  • 習慣沉默

    習慣沉默2017-05-16 17:12:12

    根据错误提示,应该是你的 Apache 没有 services/ 目录的访问权限?
    是不是项目路径不在 Apache 默认路径下,是的话要做相应的配置

    Antwort
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 17:12:12

    把location /services/ 改成 location /services

    Antwort
    0
  • StornierenAntwort