Using SuSE 10.0, Apache 2.0.54. Looked through the Apache online manual on setting up virtual hosts and created a vhosts.conf file - mostly copy/paste from a template (see listing below).
I have also set up bind on my LAN to resolve both "genesis" (IN A 192.168.1.65) and "linux-install" (IN CNAME genesis).
I restarted apache and bind daemons after changes to their respective files.
http://genesis works fine and shows index.html in "/home/www/html" but ... http://linux-install shows the same index.html as above instead of the directory listing of the Linux distribution tree I have installed @ /mnt/C.
I have tried replacing * with IP# but same result. Defining "linux-install" as A record - same result.
Any ideas/suggestions on could be missing in my setup?
================== begin vhosts.conf ==================
NameVirtualHost *:80
<VirtualHost *:80>
ServerName genesis.silverarc.biz ServerAdmin root@localhost
DocumentRoot /home/www/html/
ErrorLog /var/log/apache2/genesis-error_log CustomLog /var/log/apache2/genesis-access_log combined
HostnameLookups Off
UseCanonicalName Off
ServerSignature On
<Directory "/home/www/html/">
Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName linux-install.silverarc.biz ServerAdmin root@localhost
DocumentRoot /mnt/C
ErrorLog /var/log/apache2/linux-install-error_log CustomLog /var/log/apache2/linux-install-access_log combined
HostnameLookups Off
UseCanonicalName Off
ServerSignature On
<Directory "/mnt/C">
Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all
</Directory>
</VirtualHost>
================== end vhosts.conf ==================
Thanks.
On Sunday 07 May 2006 22:38, Arun K. Khan wrote:
Using SuSE 10.0, Apache 2.0.54. Looked through the Apache online manual on setting up virtual hosts and created a vhosts.conf file - mostly copy/paste from a template (see listing below).
wow. i too was busy setting up virtual hosts on my debian server today.
I restarted apache and bind daemons after changes to their respective files.
http://genesis works fine and shows index.html in "/home/www/html" but ... http://linux-install shows the same index.html as above instead of the directory listing of the Linux distribution tree I have installed @ /mnt/C.
I have tried replacing * with IP# but same result. Defining "linux-inNameVirtualHost *:80
Since I am using Apache 1.3.31 I dont have a vhosts.conf. Heres the relevant part of my httpd.conf:
--------------------------------------------------------------------- NameVirtualHost *:80
<VirtualHost *> ServerName localhost ServerAdmin webmaster@localhost DocumentRoot /var/www/ ErrorLog /var/log/apache/error.log CustomLog /var/log/apache/access.log combined ServerAlias 192.168.0.1 www.mydomain.org </VirtualHost>
<VirtualHost *> ServerName test.mydomain.org ServerAdmin webmaster@test.mydomain.org DocumentRoot /var/www/test-mydomain-web/
<Directory /var/www/test-mydomain-web/> Options Indexes Includes FollowSymLinks MultiViews AllowOverride None Order allow,deny Allow from all </Directory>
ErrorLog /var/log/apache/test.mydomain.org-error.log CustomLog /var/log/apache/test.mydomain.org-access.log common </VirtualHost>
<VirtualHost *> ServerName <My External IP> ServerAdmin webmaster@localhost DocumentRoot /var/www/restricted-web/ ErrorLog /var/log/apache/restricted-web-error.log CustomLog /var/log/apache/restricted-web-access.log common </VirtualHost> ---------------------------------------------------------------------
It seems that apache defaults to the first vhost if it doesnt find a matching HOST in the http header. I've simply setup the "restricted-web" entry to prevent anybody from directly using my IP to access the server. I want people only to use my domain name to refer to it. As this server can serve external requests as well as internal ones. I want it to serve a different website for the intranet as opposed to the internet so I have two different vhost entries. I dunno whether this is the right way to do it but it worked for me.
Any ideas/suggestions on could be missing in my setup?
I really cant say because the above setup works for me in Debian Sarge with Apache 1.3.31. BTW you can check your vhost config by running apache -S
On Mon, 2006-05-08 at 02:03 +0530, Dinesh Joshi wrote:
Since I am using Apache 1.3.31 I dont have a vhosts.conf. Heres the relevant part of my httpd.conf:
In httpd.conf you can "modularize" the various configs via an Include statement. That's what I did for my virtual host config.
Thanks for sharing your vhost section.
ServerAlias 192.168.0.1 www.mydomain.org
</VirtualHost>
"Server Alias ..." someone else also suggested using it although the Apache docs don't mention it.
It seems that apache defaults to the first vhost if it doesnt find a matching HOST in the http header.
Yup,
I really cant say because the above setup works for me in Debian Sarge with Apache 1.3.31. BTW you can check your vhost config by running apache -S
Will try it. There are no errors/warnings in the log files when I start httpd.
Thanks.
-- Arun Khan (knura at yahoo dot com) THE GOLDEN RULE OF ARTS AND SCIENCES The one who has the gold makes the rules.
On Monday 08 May 2006 03:58, Arun K. Khan wrote:
"Server Alias ..." someone else also suggested using it although the Apache docs don't mention it.
I dont think it will help you in your case since you are setting up subdomains.
Will try it. There are no errors/warnings in the log files when I start httpd.
Could you post your db and zone files for BIND?
Thanks to all who helped. The missing link was the "ServerAlias" directive in the second vhost. It is there in the docs; I read it but I guess it did not register in mind :)
I got the impression that Apache extracts the "hostname" from the GET received from the browser and serves the site if def. found otherwise serve the default site but ... it does needs a little help with the ServerAlias directive.
Anyway, I'll summarize my experience for NameBased vhost setup. Here I am setting up different "hostnames" under the _same_ domain name. Visitors will see different DocTree depending on the hostname given in the URL. Assumption - your DNS server is set with relevant hostnames in your domain zone file:
1. The first entry is the default host - don't need any ServerAlias _unless_ you want this site to be accessed by any other "hostname" alias. 2. Subsequent vhosts defs. must have a ServerAlias directive. The alias pointing to the FQDN of the server.
NameVirtualHost 192.168.1.65:80
<VirtualHost 192.168.1.65:80>
ServerName genesis.silverarc.biz ServerAdmin root@localhost DocumentRoot /home/www/html/ ErrorLog /var/log/apache2/genesis-error_log CustomLog /var/log/apache2/genesis-access_log combined
<Directory "/home/www/html/">
Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all
</Directory>
</VirtualHost>
<VirtualHost 192.168.1.65:80>
ServerName linux-install.silverarc.biz ServerAdmin root@localhost ServerAlias linux-install genesis.silverarc.biz genesis DocumentRoot /mnt/C ErrorLog /var/log/apache2/linux-install-error_log CustomLog /var/log/apache2/linux-install-access_log combined
<Directory "/mnt/C"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory>
</VirtualHost>
Forgot to mention this link: http://httpd.apache.org/docs/1.3/vhosts/examples.html
I'm sure theres one for Apache 2.
On Mon, 2006-05-08 at 02:14 +0530, Dinesh Joshi wrote:
Forgot to mention this link: http://httpd.apache.org/docs/1.3/vhosts/examples.html
I'm sure theres one for Apache 2.
Thanks, but as I mentioned in my OP, I started my vhost setup by reading the Apache2 online docs http://httpd.apache.org/docs/2.0/vhosts/.
-- Arun Khan (knura at yahoo dot com) Fine day to work off excess energy. Steal something heavy.
On 5/7/06, Arun K. Khan knura@yahoo.com wrote:
Using SuSE 10.0, Apache 2.0.54. Looked through the Apache online manual on setting up virtual hosts and created a vhosts.conf file - mostly copy/paste from a template (see listing below).
I have also set up bind on my LAN to resolve both "genesis" (IN A 192.168.1.65) and "linux-install" (IN CNAME genesis).
To isolate the issue, you could do away with DNS and use the /etc/hosts file instead. That way you would know if the issue is with DNS or apache.
BTW, your main site (the "ServerName" directive in your httpd.conf) should also be your first virtual host. Thats how it is with the older apache.
Regards, NMK.