Apache ProxyPass 或 ProxyPassMatch 从代理中排除文件

And*_*rei 9 mod-proxy proxypass exclude apache-2.2

我有一个 VirtualHost 设置为将所有请求代理到在端口 9000 上运行的另一台服务器。

我拥有的 :

ProxyPass / http://localhost:9000/
ProxyPassReverse / http://localhost:9000/
Run Code Online (Sandbox Code Playgroud)

我试过的:

! ProxyPass /test.html http://localhost:9000/
ProxyPass /test.html ! http://localhost:9000/
ProxyPassMatch !^/(.*\.html)$ http://localhost:9000/$1 
Run Code Online (Sandbox Code Playgroud)

没有一个工作...

我想从代理中排除一个文件或一组文件,文档说明了“! 指令在您不想反向代理子目录的情况下很有用。”,但没有示例对于那种情况。

And*_*rei 15

好吧,想通了,结果 - 显然 - 没有必要为排除的路径指定代理。

ProxyPass /somedir !

效果很好

  • 请注意,这必须在其他 ProxyPass 指令之前才能生效,因为第一个匹配是应用的。 (3认同)