The Sorrow Posted August 22, 2011 Posted August 22, 2011 (edited) Im trying to make 2 virtual hosts on one apache server. its static IP is 192.168.5.128. i can make it see the web sites through 127.0.0.1/home.html and it shows whats in the root directory for httpd </var/www/html> but i cant make it see the web sites using the names i gave the hosts on the local host or through other hosts on the intranet. [...] NameVirtualHost 192.168.5.128:80 NameVirtualHost 192.168.5.128:8080 [...] [...] <VirtualHost 192.168.5.128:80> DocumentRoot /var/www/vhost1 ServerName library.com </VirtualHost> <VirtualHost 192.168.5.128:8080> DocumentRoot /var/www/vhost2 ServerName catalogue.com </VirtualHost> [...] i can ping so i know its strictly a config issue. Any ideas? Edited August 22, 2011 by The Sorrow Quote
digip Posted August 22, 2011 Posted August 22, 2011 (edited) You have one on normal port 80 and the other on 8080, so for the second one you would have to do http://catalogue.com:8080/ to reach it. Also, might need an entry for DNS somewhere or in a hosts file, depending on how you are setting this all up. By default, the workstation trying to reach those domains, would query its gateway and its DNS servers to look them up, which means more than likely, they are tyring to go to the internet to get to those sites. Unless you explicitly tell them the address is at 192.168.5.128, they have no way to find them and will end up looking to the gateway, who will then send the request outbound to the internet. If you aren't running a DNS server at home as well, then you need to make a hosts entry to redirect their queries to the local server IP address like so: 127.0.0.1 localhost 192.168.5.128 library.com 192.168.5.128 catalogue.com Linux hosts file setup: http://elouai.com/hosts-linux.php in windows (XP and later) its in c:\windows\system32\drivers\etc\hosts Edited August 22, 2011 by digip Quote
Infiltrator Posted August 22, 2011 Posted August 22, 2011 The last router I owned a NetCom NB6Plus4, came with a built in DNS service which allowed me to create hostnames that could be mapped to individual IP addresses. It served well, since I didn't have to worry about setting up a DNS server or changing the host file on any of my computers. Just wanted to share that.... Quote
Jason Cooper Posted August 22, 2011 Posted August 22, 2011 If you are just wanting to limit based upon port numbers, which it looks like you do. Then try something like this. Listen 80 Listen 8080 NameVirtualHost *:80 NameVirtualHost *:8080 <VirtualHost *:80> DocumentRoot /var/www/vhost1 ServerName library.com </VirtualHost> <VirtualHost *:8080> DocumentRoot /var/www/vhost2 ServerName catalogue.com </VirtualHost> The *'s are wildcards so it will listen on all IP addresses. As mentioned by digip you will need to put the :8080 on then end of the hostname in the url to get to catalogue.com. Quote
digip Posted August 22, 2011 Posted August 22, 2011 (edited) If you are just wanting to limit based upon port numbers, which it looks like you do. Then try something like this. Listen 80 Listen 8080 NameVirtualHost *:80 NameVirtualHost *:8080 <VirtualHost *:80> DocumentRoot /var/www/vhost1 ServerName library.com </VirtualHost> <VirtualHost *:8080> DocumentRoot /var/www/vhost2 ServerName catalogue.com </VirtualHost> The *'s are wildcards so it will listen on all IP addresses. As mentioned by digip you will need to put the :8080 on then end of the hostname in the url to get to catalogue.com. But what of DNS, as his system would surely want to go to the internet for a fully qualified domain name, no? He is goign to need an entry in either a hosts file, or have a local DNS server standing in for DNS requests, with forwarding for internet bound addresses and "a" records for local websites on the intranet. Edited August 22, 2011 by digip Quote
Jason Cooper Posted August 22, 2011 Posted August 22, 2011 But what of DNS, as his system would surely want to go to the internet for a fully qualified domain name, no? He is goign to need an entry in either a hosts file, or have a local DNS server standing in for DNS requests, with forwarding for internet bound addresses and "a" records for local websites on the intranet. If he is wanting them to actually be library.com and catalogue.com then yes he would have to do some fudging of his DNS as you describe. Personally I would treat that as secondary task after confirming that the server is hosting the correct site on the correct port (pointing his browser at http://192.168.5.128 and http://192.168.5.128:8080 should be enough of a test). It is usually a good idea when setting these sorts of things up to do it in little steps so you know you are building upon a working base and don't have to spend as much time at the end figuring out if the problems are with the server, apache config, or DNS config that isn't working. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.