Cross domain issues, solutions – Nginx Reverse proxy blog address: blog.720uenterp rise

Cross domain problem, solution

Linked articles: Cross domain problems, solutions

solution

Cross-domain problems occur because JavaScript does not allow cross-domain calls to objects on other pages for security reasons. What if we consolidated the different domains into one domain, in other words, divided them into subdirectories, and solved the cross-domain problem? So, the idea of Nginx reverse proxy, is to use Nginx to parse the URL to determine the specific server to forward the request.

Resolve cross-domain problems

  • Customize local URL request rules, such as www.720ui.com/blog, for nginx services to forward to blog.720ui.com.
  • Configure the nginx.conf file to forward local URL interface requests with specific prefixes to real physical servers to cross domains.
server
{
    listen 80;
    server_name www720.ui.com;

    location ^~ /blog/ {
        proxy_pass http://blog.720ui.com/;}}Copy the code
  • The Nginx service forwards requests to real physical servers. The Nginx service forwards data from the real physical server to the Web side.

(after)

More wonderful articles, all in the “server-side thinking” wechat public account!