Hi,
I set up a webserver with Apache on one of the machines on the local network. There's a DNS configured for the LAN, with a dummy domain name (presbytere.local), and every machine is pingable by its hostname. The webserver runs on the machine 'buildbox'.
The webserver actually has two (static) websites on it, for testing and fiddling purposes. Each site's pages are stored respectively under /var/www/html/microlinux and /var/www/html/kikinovak. I can reach the two websites from any machine on the local network by opening a web browser at http://buildbox/microlinux/ or http://buildbox.presbytere.local/microlinux/ for the first website, and http://buildbox/kikinovak resp. http://buildbox.presbytere.local/kikinovak for the second website. So far so good.
Now I'd like to setup two virtual hosts on the server, so I can access the first site via http://microlinux.buildbox and the second site via http://kikinovak.buildbox. I tried various combinations that seemed to make sense, but to no avail.
Here's what I *think* my /etc/httpd/conf/httpd.conf should look like:
NameVirtualHost *:80
<VirtualHost *:80> ServerAdmin info@microlinux.fr DocumentRoot /var/www/html/microlinux ServerName buildbox.presbytere.local ServerAlias microlinux.buildbox.presbytere.local ErrorLog logs/microlinux-error_log CustomLog logs/microlinux-access_log common </VirtualHost>
But that doesn't work out (yes, I restarted httpd :oD), because I think what's missing here is that I have to somehow add microlinux.buildbox (and later kikinovak.buildbox) to my local DNS server (only how?)...
Here's my current Bind configuration for the local network:
First, /var/named/zone.local.presbytere:
; ; Zone DNS pour presbytere.local ; $ORIGIN presbytere.local. $TTL 1D @ IN SOA babasse hostmaster ( 2009070201 ; serial 8H ; refresh 4H ; retry 4W ; expire 1D ) ; minimum ; babasse.presbytere.local est le serveur de noms (NS) pour ce domaine NS babasse ; au cas où quelqu'un ferait une requête pour localhost.presbytere.local localhost A 127.0.0.1 ; nos machines babasse A 192.168.1.1 buildbox A 192.168.1.2 lifebook A 192.168.1.3 raymonde A 192.168.1.4 jukebox A 192.168.1.5 frankenstein A 192.168.1.6
ap A 192.168.1.253 modem A 192.168.1.254
And then, /var/named/revp.192.168.1:
; ; Résolution inverse pour le réseau 192.168.1.0 ; $ORIGIN 1.168.192.in-addr.arpa. $TTL 1D @ IN SOA babasse.presbytere.local. contact.kikinovak.net. ( 2009070201 ; serial 28800 ; refresh (8 hours) 14400 ; retry (4 hours) 2419200 ; expire (4 weeks) 86400 ; minimum (1 day) ) ; Définit le serveur de noms faisant autorité NS babasse.presbytere.local. ; Nos machines 1 PTR babasse.presbytere.local. 2 PTR buildbox.presbytere.local. 3 PTR lifebook.presbytere.local. 4 PTR raymonde.presbytere.local. 5 PTR jukebox.presbytere.local. 6 PTR frankenstein.presbytere.local.
253 PTR ap.presbytere.local. 254 PTR modem.presbytere.local.
I admit I'm a bit confused, and I don't know if I succeeded in accurately describing my ignorance here.
Any suggestions?
Niki
Niki Kovacs wrote:
But that doesn't work out (yes, I restarted httpd :oD), because I think what's missing here is that I have to somehow add microlinux.buildbox (and later kikinovak.buildbox) to my local DNS server (only how?)...
just add a record
microlinux.buildbox IN A #.#.#.#
nate
nate a écrit :
just add a record
microlinux.buildbox IN A #.#.#.#
That gives me a partial success. I added my two virtual hosts to the DNS server, like this:
babasse A 192.168.1.1 buildbox A 192.168.1.2 lifebook A 192.168.1.3 raymonde A 192.168.1.4 jukebox A 192.168.1.5 frankenstein A 192.168.1.6
ap A 192.168.1.253 modem A 192.168.1.254
microlinux.buildbox A 192.168.1.2 kikinovak.buildbox A 192.168.1.2
I increased the serial and restarted named.
Then, on the webserver, I added this to httpd.conf:
NameVirtualHost *:80
<VirtualHost *:80> ServerAdmin info@microlinux.fr DocumentRoot /var/www/html/microlinux ServerName buildbox.presbytere.local ServerAlias microlinux.buildbox.presbytere.local ErrorLog logs/microlinux-error_log CustomLog logs/microlinux-access_log common </VirtualHost>
<VirtualHost *:80> ServerAdmin contact@kikinovak.net DocumentRoot /var/www/html/kikinovak ServerName buildbox.presbytere.local ServerAlias kikinovak.buildbox.presbytere.local ErrorLog logs/kikinovak-error_log CustomLog logs/kikinovak-access_log common </VirtualHost>
... and I duly restarted httpd.
Now, I can fire up a browser anywhere on the LAN and view the first site via http://microlinux.buildbox. But curiously, when I try to view the second site via http://kikinovak.buildbox, I also get the first site at the second address. Any idea what's going on here?
Niki
Niki Kovacs wrote:
NameVirtualHost *:80
<VirtualHost *:80> ServerAdmin info@microlinux.fr DocumentRoot /var/www/html/microlinux ServerName buildbox.presbytere.local
[..]
<VirtualHost *:80> ServerAdmin contact@kikinovak.net DocumentRoot /var/www/html/kikinovak ServerName buildbox.presbytere.local
I think your issue is this, if these are different virtual hosts I would set the ServerName to be the name of the virtual host itself.
nate
nate a écrit :
I think your issue is this, if these are different virtual hosts I would set the ServerName to be the name of the virtual host itself.
I think I found the error. Not exactly sure, but here goes. My virtual host configuration works OK when I view each site with its fully qualified domain name, e. g.
- http://microlinux.buildbox.presbytere.local for site 1
- http://kikinovak.buildbox.presbytere.local for site 2
Only the shorter form doesn't work, which means http://microlinux.buildbox and http://kikinovak.buildbox both result in viewing site 1. Which lets me carefully deduce that virtual hosts need to be called by their fully qualified domain name.
Correct me if I'm wrong.
Niki
Niki Kovacs wrote:
Only the shorter form doesn't work, which means http://microlinux.buildbox and http://kikinovak.buildbox both result in viewing site 1. Which lets me carefully deduce that virtual hosts need to be called by their fully qualified domain name.
Yeah that sounds good, myself I've made it a habbit a long time ago to always call sites with their FQDN, if your just sending the short name then your browser is just using that name in the Host: header. You could try adding a virtual host or changing your config so that it includes the short name as well, apache just looks for what is in the Host: header
nate
Niki Kovacs wrote:
nate a écrit :
I think your issue is this, if these are different virtual hosts I would set the ServerName to be the name of the virtual host itself.
I think I found the error. Not exactly sure, but here goes. My virtual host configuration works OK when I view each site with its fully qualified domain name, e. g.
http://microlinux.buildbox.presbytere.local for site 1
http://kikinovak.buildbox.presbytere.local for site 2
Only the shorter form doesn't work, which means http://microlinux.buildbox and http://kikinovak.buildbox both result in viewing site 1. Which lets me carefully deduce that virtual hosts need to be called by their fully qualified domain name.
Correct me if I'm wrong.
thats what serveralias is for...
<VirtualHost *:80> ServerAdmin info@microlinux.fr DocumentRoot /var/www/html/microlinux ServerName microlinux.buildbox.presbytere.local ServerAlias microlinux.buildbox ErrorLog logs/microlinux-error_log CustomLog logs/microlinux-access_log common </VirtualHost>
<VirtualHost *:80> ServerAdmin contact@kikinovak.net DocumentRoot /var/www/html/kikinovak ServerName kikinovak.buildbox.presbytere.local ServerAlias kikinovak.buildbox ErrorLog logs/kikinovak-error_log CustomLog logs/kikinovak-access_log common </VirtualHost>
Niki Kovacs wrote:
nate a écrit :
I think your issue is this, if these are different virtual hosts I would set the ServerName to be the name of the virtual host itself.
I think I found the error. Not exactly sure, but here goes. My virtual host configuration works OK when I view each site with its fully qualified domain name, e. g.
http://microlinux.buildbox.presbytere.local for site 1
http://kikinovak.buildbox.presbytere.local for site 2
Only the shorter form doesn't work, which means http://microlinux.buildbox and http://kikinovak.buildbox both result in viewing site 1. Which lets me carefully deduce that virtual hosts need to be called by their fully qualified domain name.
Correct me if I'm wrong.
Virtual hosts are selected by matching on your ServerName setting, so it's whatever you put there - which also has to be something that works in DNS to reach it which would be the fully qualified name for anyone who doesn't have you domain in their search list. ServerName takes a single value, but if you want additional names to be accepted you can add them to a ServerAlias setting which can have more than one.