Proxy_pass configuration of nginx reverse proxy

When using nginx reverse proxy again, proxy_pass will definitely be used to set the proxy address.

The format is: proxy_pass url,

URL includes: transmission protocol (http://, https://, etc.), host name (domain name or IP), uri.

Example:

proxy_pass http://www.xxx.com/;
proxy_pass http://192.168.200.101:8080/uri;
proxy_pass unix:/tmp/www.sock;

There are several situations to note here:

Assuming server_name is www.xxx.com

When accessing http://www.xxx.com/aming/a.html, different settings have the following situations:

Example 1.

location /aming/
{
    proxy_pass http://192.168.1.10;
    ...
}

Result 1:  http://192.168.1.10/aming/a.html

Example 2.

location /aming/
{
    proxy_pass http://192.168.1.10/;
    ...
}

Result 2:  http://192.168.1.10/a.html

Example 3:

location /aming/
{
    proxy_pass http://192.168.1.10/linux/;
    ...
}

Result 3:  http://192.168.1.10/linux/a.html

Example 4:

location /aming/
{
    proxy_pass http://192.168.1.10/linux;
    ...
}

Result 4:  http://192.168.1.10/linuxa.html

 

to sum up:

To facilitate memory and standard configuration, it is recommended that all URLs after proxy_pass end with /.

proxy_pass http://192.168.1.10/linux/;

 

Reprinted from: https://www.cnblogs.com/yyxianren/p/10831511.html

Guess you like

Origin blog.csdn.net/RedaTao/article/details/108306270