Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In order to make my life easier with new vhosts popping up I set up my httpd.conf to use this:

<IfModule mod_vhost_alias.c>
  <VirtualHost *:80>
    RewriteEngine On
    RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$
    RewriteRule ^(.*)$ - [env=askapache:%2]

    RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
    RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R=301]

    ServerAlias *
    UseCanonicalName Off
    LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
    CustomLog /var/log/httpd/access_log vcommon
    VirtualDocumentRoot /web-data/vhosts/%0/httpdocs
    VirtualScriptAlias  /web-data/vhosts/%0/httpdocs
  </VirtualHost>
</IfModule>

The problem is one of the hosts needs to make use of a ProxyPass statement. I was just going to put that in a separate conf file in a conf folder in that sites root (not Doc Root outside the httpdocs folder). However I can't figure out how to do that and include it with the dynamic virtual hosting. What can I do to set up a ProxyPass just for this one host without messing up the dynamic virtual hosting setup I have?

Edit:

I've tried the following in my .htaccess file to no avail. I get a 404

RewriteEngine on
RewriteRule ^blog/$ http://blog.mydomain.com [P,L]
share|improve this question
add comment

1 Answer 1

You can probably define your proxies in a separate conf file in Apache conf dir and then use the rewrite rules with the P flag (which uses mod_proxy under the hood) in an htaccess file.

share|improve this answer
    
How would I go about doing that? –  LoneWolfPR Apr 21 at 15:41
    
Check the documentation here: httpd.apache.org/docs/current/rewrite/flags.html#flag_p –  alxgomz Apr 21 at 15:48
    
This seems overly complicated to include mod_rewrite as well. Isn't there a way to tell the system to just include an external conf file in each vhosts conf folder? Then I could just put a ProxyPass in there. –  LoneWolfPR Apr 21 at 19:55
    
This is what "Include" does but you most definitely dont want to include any file in any of your vhosts webroot, where people can upload almost anyhthing they want. That's why htaccess is for, and thats why not all directive can be used in htaccess. Proxypass cant. Rewriterules can... i dont really understand what you find so complicate here though. –  alxgomz Apr 21 at 22:38
    
Check the edit I made. I've tried adding that, but it still just gives me a 404 when I go to mydomain.com/blog instead of doing the proxy. I double checked and mod_proxy is enabled in my httpd.conf file. Is there something I missed? –  LoneWolfPR Apr 22 at 18:13
show 5 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.