How to avoid cross-domain problems through transit agents?

encountered a cross-domain problem, because the front end needs to obtain data from multiple servers, and it is a bit troublesome for the back end to obtain data and provide an interface to the front end. So I wonder if the front end can directly obtain the data of other websites.

for example, if this website is A, if you want to request the data of the three websites, can you send our request to the server automatically through a transit proxy server, and return the results automatically when you get the response?

take a look at the reverse proxy of Nginx. The current configuration

server {
    listen       8000;
    server_name  localhost;

    location / {
        proxy_pass http://localhost:3000;
    }
}

this configuration only allows A to access Nginx just as it does to B, but what about other CMI D servers? Can I configure URL to add a parameter to represent the domain name, and then Nginx automatically replace the domain name in the parameter?

but I still don"t know what to do. Is there a good solution? (v ^ _ ^) v

Dec.16,2021

I just did this two days ago. You can replace location with / image / backEnd and so on to match the messages sent to nginx, and then define each server. It seems to be a bit of a mess, for example:


    
    upstream frontEnd{
        server XXX weight=1;
    }
    
    upstream apiServer{
        server XXX weight=1;
    }
< H2 > Agent rules < / H2 >
    
    location /frontEnd{
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        -sharp 
        proxy_pass http://frontEnd;
        proxy_redirect off;
    }

    
    location /rest{
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        -sharp 
        proxy_pass http://apiServer;
        proxy_redirect off;
 }

in this way, the request for / frontEnd is sent to the front-end server, and the request for / rest is sent to the backend
if there are more complex requests that need to be matched, you can check the matching rules of nginx. You can use regular
(v ^ _ ^) v

.
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-1eac447-20be.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-1eac447-20be.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?