Nginx-Reverse-Proxy-Konfiguration für den Zugriff auf das Backend, grundlegende Fragen?
大家讲道理
大家讲道理 2017-05-16 17:10:12
0
4
507

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?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

Antworte allen(4)
伊谢尔伦

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

过去多啦不再A梦

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/;
    }
}
習慣沉默

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

伊谢尔伦

把location /services/ 改成 location /services

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!