nginx反向代理配置访问后台,基础问题?
大家讲道理
大家讲道理 2017-05-16 17:10:12
0
4
509

报错截图如下:

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.

反向代理配置如下:

请问,配置哪里出了问题?

大家讲道理
大家讲道理

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

全部回复(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

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!