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

I use mod_vhost_alias because it is really easy for me to add new vhost (I just need to create a directory).

/etc/apache2/mods-available/vhost_alias.conf

UseCanonicalName Off
VirtualDocumentRoot /var/www/%0/htdocs

/etc/apache2/sites-available/default

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

However I need to configure a custom vhost to make use of mod_proxy, so I created:

/etc/apache2/sites-available/mysite

<VirtualHost *>
    ServerName mysite.example.com
    ProxyPreserveHost On
    ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
    ProxyPass / http://192.168.1.12:7235/
    ProxyPassReverse / http://192.168.1.12:7235/
    <Location />
        Order allow,deny
        Allow from all
    </Location>
</VirtualHost>

While it is working correctly for the vhost_alias configuration, when I try to request my.example.com I got a 404 (because the hostname directory doesn't exist), and well my site is correctly enabled.

Any ideas?

share|improve this question
    
Create (empty) hostname directory? –  Lazy Badger Mar 14 '12 at 23:00

1 Answer 1

up vote 0 down vote accepted

Move your VirtualDocumentRoot /var/www/%0/htdocs directive out of /etc/apache2/mods-available/vhost_alias.conf, and into the <VirtualHost> block in /etc/apache2/sites-available/default; you don't want it applying to everything.

Also - change your vhost definition in /etc/apache2/sites-available/mysite from:

<VirtualHost *>

to:

<VirtualHost *:80>

.. and make sure you have a NameVirtualHost *:80 directive somewhere (ports.conf?), so that your second vhost actually gets requests.

share|improve this answer

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.