簡體   English   中英

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/$1
ProxyPass / http://192.168.65.203:2022/
ProxyPassReverse / http://192.168.65.203:2022/

問題:仍從后端服務器拾取圖像。 如果我禁用proxypass和proxypassreserve,它可以正常工作(可以從httpd服務器加載圖像)。

期望:我如何控制是否找到圖像(按照別名規則),它不應該用於proxypass? 或還有其他方法嗎?

將[1]替換為[2],然后嘗試:

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

[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”和指令! 就像停止代理一樣。 在此處查看有關此指令的更多詳細信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM