[nzlug] no-ip.com , ipcop and apache2
Nick 'Zaf' Clifford
zaf at nrc.co.nz
Mon Feb 11 18:33:01 NZDT 2008
Nevyn wrote:
> Hi,
>
> I'm trying to come up with a way to host a couple of websites on my network.
>
<snip>
> The problem is that no matter which site I go to (say nevyn1.no-ip.com
> and nevyn2.no-ip.com), everything seems to be served up by the
> nevyn2.no-ip.com despite me putting both definitions into a single
> file and putting nevyn2.no-ip.com second just for testing. I looked at
> the logs and the referral site is coming up as "-" so it's getting
> lost there somewhere.
>
> Sample of the log file (using combined format as grabbed from here:
> http://httpd.apache.org/docs/2.2/logs.html):
> 192.168.0.1 - - [11/Feb/2008:17:27:22 +1300] "GET / HTTP/1.1" 304 -
> "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.12)
> Gecko/20080207 Ubuntu/7.10 (gutsy) Firefox/2.0.0.12"
>
>
<snip>
Ok, first, Referer isn't playing any effect here. Virtual hosting (two
domains, one IP) has nothing to do with Referer.
You need to read up the document on Apache Virtual Hosting. But to
summerize:
The config should look *something* like this:
--BEGIN--
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.myfirstdomain.com
DocumentRoot /var/www/myfirstdomain/
</VirtualHost>
<VirtualHost *:80>
ServerName www.myseconddomain.com
DocumentRoot /var/www/mysecondomain/
</VirtualHost>
--END--
This tells apache we want a Name based Virtual host on all interfaces
(eg multiple domains, one IP) (vs different IPs for each domain)
And creates two virtual hosts, myfirstdomain.com and myseconddomain.com,
and has the files in the respective directories
That is small clip of the relevant parts of the config.
You'll need to have a lot more than just those lines in the apache config.
Note that most Apache setups use multiple files, for example on Ubuntu,
all of the indiviual sites are suppose to have their own file in
/etc/apache2/sites-available and you need to use a2ensite to
enable/disable each site.
If you have such a setup, try following the distro's setup guides.
Also be aware that many problems stem from being inside the firewall
when trying virtual hosting. My suggestion for that is to try it from
outside (eg VNC to a remote machine, and try from outside), or use
telnet direct to the apache server
eg:
# telnet myapachebox 80
GET / HTTP/1.0
Host: www.myfirstdomain.com:80
(press enter twice after the Host: line and you should get the raw html
from the page back. It helps of course if you have a simple page that
says: THIS IS THE FIRST DOMAIN, and THIS IS THE SECOND so you can tell
the difference easily :))
Nick
More information about the NZLUG
mailing list