ProxyPass for specific vhost with mod_rewrite
Posted
by
Steve Robbins
on Server Fault
See other posts from Server Fault
or by Steve Robbins
Published on 2013-11-07T03:52:45Z
Indexed on
2013/11/08
10:01 UTC
Read the original article
Hit count: 332
I have a web server that it set up to dynamically server different document roots for different domains
<VirtualHost *:80>
<IfModule mod_rewrite.c>
# Stage sites :: www.[document root].server.company.com => /home/www/[document root]
RewriteCond %{HTTP_HOST} ^www\.[^.]+\.server\.company\.com$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^www\.([^.]+)\.server\.company\.com(.*) /home/www/$1/$2 [L]
</IfModule>
</VirtualHost>
This makes it so that www.foo.server.company.com
will serve the document root of server.company.com:/home/www/foo/
For one of these sites, I need to add a ProxyPass
, but I only want it to be applied to that one site. I tried something like
<VirtualHost *:80>
<Directory /home/www/foo>
UseCanonicalName Off
ProxyPreserveHost On
ProxyRequests Off
ProxyPass /services http://www-test.foo.com/services
ProxyPassReverse /services http://www-test.foo.com/services
</Directory>
</VirtualHost>
But then I get these errors
ProxyPreserveHost not allowed here
ProxyPass|ProxyPassMatch can not have a path when defined in a location.
How can I set up a ProxyPass
for a single virtual host?
© Server Fault or respective owner