Apache HTTPD - Virtualhost 中的 AliasMatch 和 ProxyPass

Apache HTTPD - AliasMatch and ProxyPass in Virtualhost

我有这样的后端 API:

http://192.168.65.203:2022/page/index.jsp

并且我在命中后端之前将 Apache httpd 服务器作为第一层。我将端口设置为 8090。

现在我想要图像文件只能从 httpd 服务器获取,而不是从后端服务器获取。所以我的 VirtualHost 看起来像这样:

<VirtualHost *:8090>
ProxyPreserveHost On
ProxyRequests off
<Directory "/usr/share/myfile">
    Options Indexes FollowSymLinks
    AllowOverride None
    order allow,deny
    Allow from all
    Require all granted
</Directory>
AliasMatch ^/(.*\.gif|.*\.jpg|.*\.jpeg|.*\.png|.*\.css|.*\.swf)$ /usr/share/myfile/
ProxyPass / http://192.168.65.203:2022/
ProxyPassReverse / http://192.168.65.203:2022/

问题:仍然从后端服务器获取图像。如果我禁用 proxypass 和 proxypassreserve,它工作正常(图像可以从 httpd 服务器加载)。

预期:我如何控制是否找到图像(在别名规则下)它不应该用于 proxypass?或者还有其他方法吗?

用 [2] 替换 [1] 并尝试:

[1] : 
AliasMatch ^/(.*\.gif|.*\.jpg|.*\.jpeg|.*\.png|.*\.css|.*\.swf)$ /usr/share/myfile/

[2] :
ProxyPassMatch ^/(*.gif)$   !
ProxyPassMatch ^/(*.jpg)$   !
ProxyPassMatch ^/(*.jpeg)$  !
ProxyPassMatch ^/(*.png)$   !
ProxyPassMatch ^/(*.css)$   !
ProxyPassMatch ^/(*.swf)$   !

指令!是需要的。以下是我的问题的解决方案..

<VirtualHost *:8090>
ProxyPreserveHost On
ProxyRequests off
<Directory "/usr/share/myfile">
    Options Indexes FollowSymLinks
    AllowOverride None
    order allow,deny
    Allow from all
    Require all granted
</Directory>
DocumentRoot "/usr/share/myfile"
ProxyPassMatch ^/(.*\.gif|.*\.jpg|.*\.jpeg|.*\.png|.*\.css|.*\.swf)$ !
ProxyPass / http://192.168.65.203:2022/
ProxyPassReverse / http://192.168.65.203:2022/
</VirtualHost>

当请求是图像类型时,它将转到本地文件系统“/usr/share/myfile”和指令!就像停止代理。检查 here 以获取有关此指令的更多详细信息。