Fal*_*ken 13 linux nginx reverse-proxy proxypass
在 Apache 上,您可以 ProxyPass 除了一个或多个子目录(带有“!”)之外的所有内容。
ProxyPass /subdir !
ProxyPass / http://localhost:9999/
Run Code Online (Sandbox Code Playgroud)
什么是 Nginx 等价物?
我的第一个猜测显然不起作用:
location /subdir {
root /var/www/site/subdir;
}
location / {
proxy_pass http://localhost:9999/ ;
}
Run Code Online (Sandbox Code Playgroud)
Chr*_*rin 14
您可以将 proxy_pass 绑定到您喜欢的路径,就像这样
location = / {
proxy_pass http://localhost:9999/;
}
Run Code Online (Sandbox Code Playgroud)
这确保不会通过其他路径,但是 /
或者
您可以仅对要匹配的子目录使用此语法
location ^~ /subdir {
alias /var/www/site/subdir;
}
location / {
proxy_pass http://localhost:9999/ ;
}
Run Code Online (Sandbox Code Playgroud)
在^~
该子目录相匹配,然后停止搜索,因此/
将不会被执行。它是在此处描述的。