Nginx proxy_pass instructions '/' Use considerations _nginx

Source: Internet
Author: User

1. Proxy_pass Configuration Instructions

Do not take/

Copy Code code as follows:

location/test/
{
Proxy_pass http://t6:8300;
}

With

Copy Code code as follows:

location/test/
{
Proxy_pass http://t6:8300/;
}

The above two configurations, the difference is only proxy_pass forwarded by the path after the "/"

For Case 1, if the access URL = http://server/test/test.jsp, then after the Nginx agent, the request path will ask http://proxy_pass/test/test.jsp, test/as the root path, request test /Path of resources

For Case 2, if the access URL = http://server/test/test.jsp, the request path becomes http://proxy_pass/test.jsp after the proxy is nginx, directly accessing the server's root resource

2. Typical examples

Access different applications and resources under the same domain, depending on the root path
For example: a applies http://server/a; b Application Http://server/b

A application and B application together access domain name http://server;
When configuring Nginx agent forwarding, if the configuration of Scenario 2 is used, it can cause access to http://server/a/test.jsp when the agent to http://proxy_pass/ test.jsp, causing no access to the correct resources, the page if there is access to the root resources, will also be http://server as the root path to access resources, resulting in resource failure

In view of this kind of situation, need to use the situation 1, respectively for no application, set different root resource path, and ensure that the root path after the agent is still valid

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.