0

我有一个包含常见配置项的 VirtualHost 块,其中一个指令是 ProxyPreserveHost。

我可以“程序地”关闭 Rewrite 指令的 ProxyPreserveHost,然后让 include 重新打开它吗?例如:

<VirtualHost *:80>
ServerName www.blah.com
...
...
ProxyPreserveHost off
RewriteRule /somepath http://otherhost/otherpath [P]

Include /path/to/file/turning-on-ProxyPreserveHost

</VirtualHost>

另一个主机位于 CDN 上,并且保留主机会产生一些名称解析问题,该问题不允许代理主机命名空间中的内容。

ProxyReserveHost 仅允许在服务器配置或虚拟主机中使用。看起来我不能为 ProxyPass 和 ProxyPassReverse 指令(封装在 mod_rewrite 的代理标志中)有选择地关闭它。

4

1 回答 1

0

以下是在互联网上找到的,解决了我的困境。顺便说一句,有一个开放的功能请求可以ProxyPreserveHost在 Apache HTTPD 项目中的位置和目录级别进行配置。

<IfModule mod_headers.c>
  <代理“http://${build.replace.host}/”>
    RequestHeader 设置主机 ${build.replace.external.host}
  </代理>
  RewriteRule ^/proxypath/ http://${build.replace.external.host}/path/to/resource.html [P]
  ProxyPassReverse /proxypath/ http://${build.replace.external.host}/path/to/resource.html
</IfModule>
于 2010-05-12T18:15:12.763 回答