In addition to using Cors to achieve Cross-domain access, Nginx has a relatively simple way of implementing the proxy function of the Proxy_pass module:
For example, if you need to implement Cross-domain access for the WWW and M stations, you only need to add the following configuration to the M station's configuration file:
### all interface requests are/H5API with the ###
location/h5api {
# representation (. *) section. The parameters in the first pair () are $, and the second pair () is $, and so
rewrite^.+h5api/? *) $/$1 break;
Includeuwsgi_params;
Proxy_pass http://www-dev.abc.com/;
}
The principle is very simple, the Nginx server deceives the browser, let it think that this is a homologous call, thus resolving the browser's cross-domain problem. By rewriting the URL, it deceives the real server and makes it think that the HTTP request is directly from the user's browser.