Nginx reverse proxy solves cross-domain problems

this is my request code

            $.ajax({
                url:"/apis/h5/policy.do",
                type:"post",
                data:{pageSize:7},
                success:function(data){
                    console.log(data)
                }
            })

this is my nginx configuration

 server {
        listen       8024;
        server_name  localhost;

        -sharpcharset koi8-r;

        -sharpaccess_log  logs/host.access.log  main;

        location / {
             proxy_pass http://localhost:8024;
        }
        location /apis {
            rewrite  ^.+apis/?(.*)$ /$1 break;
            include  uwsgi_params;
               proxy_pass   http://wap.zhuogan.cn/smartApp;
           }
        
    }
    

the browser saves as shown in the following figure

Jan.16,2022

nginx not familiar, but also found a problem

tested, your interface should be http://wap.zhuogan.cn/smartApp/h5/policy.do can access

so you can't bring in apis when you proxy, or intercept apis when forwarding

when you bring it in.

you can try more on how to change it.


your Nginx listens for requests with port 80 and Host localhost , but you call port 8020 directly in the browser without adding the hostname, and you don't use Nginx at all.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b350d9-2bf8f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b350d9-2bf8f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?