Jump to content

Apache Help


The Sorrow

Recommended Posts

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
[...]

[...]
&lt;VirtualHost 192.168.5.128:80&gt;
DocumentRoot /var/www/vhost1
ServerName library.com

&lt;/VirtualHost&gt;

&lt;VirtualHost 192.168.5.128:8080&gt;
DocumentRoot /var/www/vhost2
ServerName catalogue.com

&lt;/VirtualHost&gt;
[...]

i can ping so i know its strictly a config issue.

Any ideas?

Edited by The Sorrow
Link to comment
Share on other sites

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 by digip
Link to comment
Share on other sites

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....

Link to comment
Share on other sites

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

&lt;VirtualHost *:80&gt;
    DocumentRoot /var/www/vhost1
    ServerName library.com
&lt;/VirtualHost&gt;

&lt;VirtualHost *:8080&gt;
    DocumentRoot /var/www/vhost2
    ServerName catalogue.com
&lt;/VirtualHost&gt;

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.

Link to comment
Share on other sites

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

&lt;VirtualHost *:80&gt;
    DocumentRoot /var/www/vhost1
    ServerName library.com
&lt;/VirtualHost&gt;

&lt;VirtualHost *:8080&gt;
    DocumentRoot /var/www/vhost2
    ServerName catalogue.com
&lt;/VirtualHost&gt;

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 by digip
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...