views:

31

answers:

1

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).

A: 

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}/"&gt;
    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>
javafueled