search

Home  >  Q&A  >  body text

nginx reverse proxy configuration to access the backend, basic questions?

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?

大家讲道理大家讲道理2756 days ago533

reply all(4)I'll reply

  • 伊谢尔伦

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

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

    reply
    0
  • 过去多啦不再A梦

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

    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/;
        }
    }

    reply
    0
  • 習慣沉默

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

    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

    reply
    0
  • 伊谢尔伦

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

    Change location /services/ to location /services

    reply
    0
  • Cancelreply