Wetts's blog

Stay Hungry, Stay Foolish.

0%

Nginx-语法-proxy_pass中的路径问题

^~来匹配

http://127.0.0.1:81/demo/test.html

http://host/

1
2
3
location ^~ /demo/ {
proxy_pass http://127.0.0.1:8080/;
}

代理到http://127.0.0.1:8080/test.html

http://host

1
2
3
location ^~ /demo/ {
proxy_pass http://127.0.0.1:8080;
}

代理到http://127.0.0.1:8080/demo/test.html

http://host/<path>/

1
2
3
location ^~ /demo/ {
proxy_pass http://127.0.0.1:8080/a/;
}

代理到http://127.0.0.1:8080/a/test.html

http://host/<path>

1
2
3
location ^~ /demo/ {
proxy_pass http://127.0.0.1:8080/a;
}

代理到http://127.0.0.1:8080/atest.html

=来匹配

http://127.0.0.1:81/demo/

http://host/

1
2
3
location = /demo/ {
proxy_pass http://127.0.0.1:8080/;
}

代理到http://127.0.0.1:8080/

http://host

1
2
3
location = /demo/ {
proxy_pass http://127.0.0.1:8080;
}

代理到http://127.0.0.1:8080/demo/