[Techtalk] Apache and name based virtual hosts
Diggy Bell
diggy at dbsoftdev.com
Tue Sep 23 14:05:49 EST 2003
Hi Tiera,
I usually set up my virtual hosts a little differently. One caveat, I'm not
doing any SSL, but if I'm reading the Apache docs right, this should work.
Here's what I would suggest for your configuration:
NameVirtualHost *:*
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName example1.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/example2
ServerName example2.com
ErrorLog logs/example2-error_log
CustomLog logs/example2-access_log common
</VirtualHost>
<VirtualHost *:443>
DocumentRoot "/var/www/html"
ServerName example1.com
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
[snip]
</VirtualHost>
As I read the docs, the <VirtualHost *[:port]> indicates which network
interface should be listened on. The '*' indicates all adapteres. The
<port> number can be used to force different port numbers to different
virtual hosts, or in your case, to SSL. When the request is received on the
interface, it is checked against the ServerName values to determine which
DocumentRoot is to be used.
I haven't had a chance to verify this, but hopefully I'm not too far off...
William D. 'Diggy' Bell
Principal
DB Software Development
http://www.dbsoftdev.com
----- Original Message -----
From: "tiera" <tiera at comhem.se>
To: <techtalk at linuxchix.org>
Sent: Tuesday, September 23, 2003 12:15 PM
Subject: [Techtalk] Apache and name based virtual hosts
> Hi
>
> I'm trying to configure Apache (Apache/2.0.40 (Red Hat Linux)) to use name
> based virtual hosts. I tried to follow the apache documentation but I must
> have done something wrong because things aren't working.
> My default domain should be example1.com and the other domain should be
> example2.com.
> This is what I've added to the end of my httpd.conf:
>
> NameVirtualHost *:80
>
> <VirtualHost *:80>
> DocumentRoot /var/www/html
> ServerName example1.com
> </VirtualHost>
>
> <VirtualHost example2.com:80>
> DocumentRoot /var/www/example2
> ServerName example2.com
> ErrorLog logs/example2-error_log
> CustomLog logs/example2-access_log common
> </VirtualHost>
>
> And I also want ssl for the default domain so for that I have:
> <VirtualHost example1.com:443>
> DocumentRoot "/var/www/html"
> ServerName example1.com:443
> ErrorLog logs/ssl_error_log
> TransferLog logs/ssl_access_log
> [snip]
> </VirtualHost>
>
> Apache starts ok and everything. But if i try to go to
example1.com/page.html
> I get a 404 error that gives example2.com as the server adress. If I visit
> https://example1.com/page.html everythings ok. If I visit
> https://example2.com/page.html I get the same page as before, which I
don't
> think should work because page.html is in the document root for
example1.com.
> So obviously there's something I've misunderstood. But I've done just as
the
> example in the Apache docs except that I've put :80 at the end because I
also
> have the ssl configuration. I've tried to put example1.com instead of the
*
> in the above configuration directives, but then I get different errors
about
> missing NameVirtualHost and that example2.com doesn't belong and so on.
>
> Does anyone see what I am doing wrong?
>
> /Tiera
>
>
> _______________________________________________
> Techtalk mailing list
> Techtalk at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/techtalk
>
>
More information about the Techtalk
mailing list