nginx reverse proxy configuration to access the backend, basic questions?
大家讲道理
大家讲道理 2017-05-16 17:10:12
0
4
566

The error screenshot is as follows:

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.

The reverse proxy configuration is as follows:

Excuse me, what is wrong with the configuration?

大家讲道理
大家讲道理

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

reply all(4)
伊谢尔伦

It’s a cross-domain issue, see /a/11...

过去多啦不再A梦

Just use localhost for server_name. There is no need to include a port, otherwise http://localhost:9090/services/ will be forwarded to port 9000. There should be no problem with configuring other parts. I would like to make some suggestions. I would like to post code instead of pictures for nginx configuration. Thank you.

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

According to the error message, it should be that your Apache does not have access permissions to the services/ directory?
Is the project path not in the Apache default path? If so, you need to configure it accordingly

伊谢尔伦

Change location /services/ to location /services

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template