Cross-domain access using Proxy_pass __nginx

Source: Internet
Author: User
Tags http request nginx server

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.