开发者

Can I turn off an Apache Directive then turn it on in an include?

I have a VirtualHost block that includes common configuration items, one directive is ProxyPreserveHost.

Can I "procedurally" turn off ProxyPreserveHost for a Rewrite directive then have the include turn it back on? For example:

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

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

</VirtualHost>

The otherhost is on a CDN and preserving the host is creating some name resolution issue that is not allowing the proxying of content in the 开发者_如何学编程host namespace.

ProxyReserveHost is only allowed in a Server Config or VirtualHost. It doesn't look like I can selectively turn it off for the ProxyPass and ProxyPassReverse directives (encapsulated in the proxy flag of mod_rewrite).


The following, found on the internet, addressed my dilemma. As an aside, there is an open feature request to make ProxyPreserveHost configurable at the Location and Directory level within the Apache HTTPD project.

<IfModule mod_headers.c>
  <Proxy "http://${build.replace.host}/">
    RequestHeader set Host ${build.replace.external.host}
  </Proxy>
  RewriteRule      ^/proxypath/ http://${build.replace.external.host}/path/to/resource.html [P]
  ProxyPassReverse /proxypath/ http://${build.replace.external.host}/path/to/resource.html
</IfModule>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜