Virtual Hosting Problems

Gerald Combs gerald at ethereal.com
Wed Apr 16 18:50:03 CDT 2003


On Wed, 16 Apr 2003, jose sanchez wrote:

> What I'm actually doing is this. 
> The domains are registered at registerfly.com, this
> company offers free domain masking. I have them
> masking the domains to my ip (that's probably why you
> are getting a response from an IIS server), I've done
> this on the past and have worked correctly (I didn't
> have a firewall between the outside and the server).
> The VirtualHosting setup I had is the same I have now
> so, I don't know why is not working. 

It looks like the problem is with the configuration at RegisterFly.  When
I connect to http://www.albertopujols.com with my browser, the following
conversation happens:

--------

GET / HTTP/1.1
Host: www.albertopujols.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2.1)
Gecko/20021130
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/pn
g,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1
Accept-Language: en-us, en;q=0.50
Accept-Encoding: gzip, deflate, compress;q=0.9
Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66
Keep-Alive: 300
Connection: keep-alive

HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Connection: close
Content-Length: 466
Content-Type: text/html
Cache-control: private

<HTML>
<HEAD><TITLE></TITLE></HEAD>
<FRAMESET ROWS="100%, *" frameborder="no" framespacing=0 border=0>
<FRAME SRC="http://65.28.15.82" NAME="mainwindow" frameborder="no"
framespacing="0" marginheight="0" marginwidth="0"></FRAME>
</FRAMESET><NOFRAMES><CENTER><H2>Your browser does not support frames.  We
recommend upgrading your browser.</H2>
<br><br>Click here to enter the page: <a
href="http://65.28.15.82">http://65.28.15.82</a></CENTER></NOFRAMES></HTML>

--------

Note that RegisterFly's server returns a frameset pointing to 65.28.15.82,
which I assume is your server's real address.  This has the effect of
redirecting the connection (I'm guessing that this is the "masking"
they're talking about), resulting in another conversation:

--------

GET / HTTP/1.1
Host: 65.28.15.82
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2.1)
Gecko/20021130
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/pn
g,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1
Accept-Language: en-us, en;q=0.50
Accept-Encoding: gzip, deflate, compress;q=0.9
Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.albertopujols.com/

--------

There is a trick involved with name-based virtual hosts.  Since you have a
single IP address serving multiple web sites, the browser has to pass a
hint to the web server to tell it what site it's looking for.  This is
done via the "Host:" header that the browser passes to the server.

Note that in the initial connection (to RegisterFly), the "Host:" header
points to www.albertopujols.com.  The second connection (to your server),
the "Host:" header is set to 65.28.15.82.  There is no way for Apache to
figure out which server the browser is asking for, so it serves up the
default one for your NameVirtualHost address.  Your Apache configuration
is probably fine.

There are two ways to fix this:

  - Don't use RegisterFly's "masking" feature.  Instead, point the DNS
    entries for each site directly to your server's address.

  - Note that the second request has the "Referer:" header set to
    http://www.albertopujols.com/.  You could probably Apache
    to use this to serve out the correct web content.  

The first way would be the easiest.  The second method involves something
on the order of writing a custom handler in mod_perl.




More information about the Kclug mailing list