Click to See Complete Forum and Search --> : Accessing individual sites in a multiple hosted environment


Wibble
04-18-2006, 03:09 PM
OK, here is the scenario. I have 3 websites hosted on an Apache 2.0 webserver.

Externally, there is no problem with accessing them, everything works fine. However, I cannot access the sites internally on my LAN. If I type the IP address of the server in a web browser, it will display the first site listed in the vhosts.conf file.

How can I access the other sites on the server, without using the full URL of the site?

hard candy
04-18-2006, 04:34 PM
Do you need a ServerAlias directive in the virtual host:
" <VirtualHost *>
ServerName server.domain.com
ServerAlias server server2.domain.com server2
...
</VirtualHost>

from Apache (http://httpd.apache.org/docs/1.3/vhosts/name-based.html)

bwkaz
04-18-2006, 09:04 PM
How can I access the other sites on the server, without using the full URL of the site? You have to use the full domain name of the site.

Apache chooses which VirtualHost to use based on the HTTP 1.0 and 1.1 "Host:" header, which pretty much any browser sends nowadays. (Even IE4/NN4. :p) The browser determines what to send as the contents of the Host: header based on the URL you type in (it uses the server-name portion).

So you MUST use the full domain name of the virtual host in order to see that virtual host, no matter where you're asking for the page from (internal or external). One way to get vhosting to work properly "internally" is if you control the DNS server used by internal clients: set up a CNAME for each vhost to point at the box's real name. If you don't run internal DNS, you'll probably have to edit peoples' /etc/hosts files.