Nginx solves cross-domain configuration problems

vue project wants to use nginx to solve cross-domain problems

I know the reason for the following problem. Now I have a new problem. Nginx listens to port 8080 to transfer locahost:8080/apis to another address, but node is also listening for 8080 conflicts.

configuration:

server {
    listen       8080;
    server_name  localhost;

    -sharpcharset koi8-r;

    -sharpaccess_log  logs/host.access.log  main;
    
    location /apis{
        proxy_pass http://baidu.com;
    }
}

after this configuration, access to http://localhost:8080/apis jumps to http://localhost:8080/apis-sharp/index instead of baidu.com?

May.16,2021

location ~ ^ / apis/ (. ) ${

if ($request_uri ~* ^/apis/(.*)$) {
    rewrite /apis/(.*) /$1 break;
}
proxy_pass http://baidu.com;

}


you said conflict, why not change one of the ports

Menu