在Apache上,您可以使用ProxyPass除
一个或多个子目录(带“!”)之外的所有
内容.
ProxyPass /subdir !
ProxyPass / http://localhost:9999/
什么是Nginx等价物?
我的第一个猜测显然不起作用:
location /subdir {
root /var/www/site/subdir;
}
location / {
proxy_pass http://localhost:9999/ ;
}
您可以将proxy_pass绑定到您喜欢的路径,就像这样
location = / {
proxy_pass http://localhost:9999/;
}
这确保不会传递其他路径但/
要么
您可以将此语法用于仅匹配的子目录
location ^~ /subdir {
alias /var/www/site/subdir;
}
location / {
proxy_pass http://localhost:9999/ ;
}
^〜匹配子目录然后停止搜索,因此/不会执行.它被描述为here.