当尝试使用 mod_substitute 和 mod_filter 替换文本内容类型的内容时,它不适用于反向代理配置。
<virtualhost *:80>
ServerName rp
ProxyRequests Off
ProxyPreserveHost Off
<Location />
ProxyPass http://site/
ProxyPassReverse http://site/
FilterDeclare replace
FilterProvider replace SUBSTITUTE resp=Content-Type $text/
FilterProtocol replace "change=yes proxy=transform cache=no"
FilterChain +replace
FilterTrace replace 1
Substitute "s/foo/bar/in"
</Location>
</virtualhost>
请求标头如下所示
Host: site
Cache-Control: max-age=0
Accept: image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.102 Safari/537.36
Referer: http://rp/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
X-Forwarded-For: 10.1.1.107
X-Forwarded-Host: rp
X-Forwarded-Server: rp
Connection: Keep-Alive
这可能是什么原因造成的?
答案1
这有效...
<VirtualHost *:80>
ProxyRequests Off
ProxyPreserveHost Off
ServerName rp
ProxyPass / http://site/
ProxyPassReverse / http://site/
RewriteEngine On
SetOutputFilter INFLATE;proxy-html;DEFLATE
ProxyHTMLURLMap http://site http://rp
</VirtualHost>