Re: dynamic/mass virtual hosts with www.* alias and localhost...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

actually your description of you want to achieve, and what already works is a 
bit confusing.  Do you want to serve the dynamic hosts only, or do you have 
an additional default site?

More comments inline.  

On Wednesday 06 May 2009 04:04:39 wayne wrote:
> enable mass/dynamic virtual hosts, allowing each virtual host to be
> accessed via example.com AND www.example.com, without creating a
> VirtualHost directive for each host.
>

> NameVirtualHost *

This is not needed for dynamic vhosts, and has no influence on the 
configuration that is outside any vhost directive.

> UseCanonicalName Off
> VirtualDocumentRoot /var/www/sites/%0/www
> VirtualScriptAlias /var/www/sites/%0/cgi-bin
>
> which works fine.  i can access all the sites listed in /var/www/sites/
> (once they are added to /etc/hosts of course, in both their
> www.example.com and example.com forms).  

So at that point, what does work? Only the domain, or also the www.domain?
I assume that the latter does not work. You have two ways:
1. change the directory  interpolation of the VirtualDocumentRoot and  
VirtualScriptAlias e.g. to   /var/www/sites/%-2.0.%-1
that means the directory name is the second last domain part, a dot, and then 
the last domain part. This enables www.domain as well as any subdomain that 
resolves to your apache.
2. simply symlink the domain directory, e.g. www.domain.tld -> domain.tld and 
leave the directory interpolation as is.

> then, i attempt to make a 
> VirtualHost directive for the default host that lists the alias:
>
> <VirtualHost *>
> 	ServerName default
> 	ServerAlias www.*
wildcards are only supported for the first domain part of the alias AFAIK.
> 	DocumentRoot /var/www/
I think it is a bad idea to have (Virtual)DocumentRoots of hostzs overlap each 
other.
> </VirtualHost>
> unfortunately this does nothing.  the virtual hosts are only accessible
> via their domain names WITHOUT the www. prefix.

What is this this VHost supposed to do? Define the default site, or provide 
common configuration for the dynamic vhosts? The latter thas not work at all, 
dynamic  vhosts have nothing to do with a <VirtualHost> container. You also 
cannot define ServerAliases for the dynamic vhosts at all, use directory 
interpolation or symlinks as described above.

> 	in addition, i can no longer access the default DocumentRoot via
> localhost or 127.0.0.1. 

Sure, you defined NameVirtualHost * and <VirtualHost *>. All requests are 
directed to VHosts, none reaches the main server configuration

> 	here are my details: running Apache/2.2.8 (Ubuntu) Mar 10 2009 18:09:05
> on Ubuntu Hardy 8.04 with kernel 2.6.24-23 and all latest updates
> applied.  i have tried it with/without the default "sites-enabled"
> Debian config, to no luck.

If you use the debian package, I'd recommend using its site configuration 
mechanism, it is quite convenient. If you only need the dynamic vhosts, put 
the config in the default site. If you have one or more other sites, put the 
dynamic vhosts inside a <VirtualHost> with a specific IP address.

Rainer

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux