下面使用一个简单的例子来说明路径替换,配置了两个路径指向同一个项目。
location ^~ /internal/project/ {
allow 127.0.0.1;
allow 172.16.0.0/16;
allow 172.17.93.0/24;
deny all;
proxy_pass https://example.com/external/project/;
}
location ~ /external/ {
root /var/www/html;
index index.html;
}
Project 路径
/var/www/html/external/project/index.html
https://example.com/internal/project/ // can access from local
https://example.com/external/project/ // can access from everywhere
配置1,使用下面的配置也可以
location ^~ /internal/ {
allow 127.0.0.1;
allow 172.16.0.0/16;
allow 172.17.93.0/24;
deny all;
proxy_pass https://example.com/external/;
}