[Gllug] mod_vhost_alias
Paul
paul at rbg.uklinux.net
Wed Nov 27 20:22:09 UTC 2002
On Wed, 2002-11-27 at 19:54, Paul wrote:
> On Tue, 2002-11-26 at 14:09, The Flying Hamster wrote:
> > On Tue, Nov 26, 2002 at 09:59:26AM +0000, Jason Clifford wrote:
> > > On 25 Nov 2002, Paul wrote:
> > >
> > > > Is it possible in Apache to have most virtual hosts dealt with by
> > > > mod_vhost_alias, but override this for some special virtual hosts. e.g.
> > > > to get separate logfiles etc?
> > > >
> > > > I've tried putting the <VirtualHost ... > section first for a special
> > > > hostname and then the general VirtualDocumentRoot directive later but
> > > > this doesn't seem to work - it all went through the mod_vhost_alias
> > > > route.
> > >
> > > I always use a separate instance of httpd for mod_vhost_alias services and
> > > have those which require specific configuration running on a separate IP.
> > > If you list the <VirtualHost...> instances before you list the
> > > mod_vhost_alias ones it may work but I've not actually tried it.
> >
> > If there's a VirtualHost block for a given site then the directives in
> > there will come into effect, but only after a server reload. We use
> > it to get customers up and running instantly but at the expense of
> > logging not kicking properly until the midnight reload.
>
> OK I think I've got this working now.
>
> The thing I didn't do at first was put the VirtualDocumentRoot line inside a <VirtualHost>
> container but having done this it seems to work. Because if you're using
> VirtualDocumentRoot on its own you don't need it enclosed.
>
> So my relevant test setup is:
>
> UseCanonicalName Off
> NameVirtualHost 127.0.0.1:80
>
> <VirtualHost *>
> DocumentRoot /var/www/foo/htdocs
> ServerName foo.com
> </VirtualHost>
>
> <VirtualHost *>
> VirtualDocumentRoot /var/www/%0
> </VirtualHost>
>
> then with foo.com and bar.com set up to resolve to 127.0.0.1 in /etc/resolv.conf
> it serves foo.com using the first VirtualHost section and bar.com using the second
> (mod_vhost_alias) VirtualHost section.
Oops, didn't test it thoroughly enough before posting.
The mod_vhost_alias one should go first (so it becomes the "default" virtual host)
and also for some reason you need to explicitly show the IP address for each VirtualHost.
If I had them both as "*" as above, foo.com gave a "404 Not Found". Also I got
this when restarting apache:
[warn] _default_ VirtualHost overlap on port 80, the first has precedence
so he correct version is:
UseCanonicalName On
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1>
UseCanonicalName Off
VirtualDocumentRoot /var/www/%0
</VirtualHost>
<VirtualHost 127.0.0.1>
DocumentRoot /var/www/foo/htdocs
ServerName foo.com
</VirtualHost>
this is using Apache 1.3.26 in Debian unstable.
--
Gllug mailing list - Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug
More information about the GLLUG
mailing list