For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > October 2006 > need help with http headers and apache virtual hosts









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author need help with http headers and apache virtual hosts
Geo

2006-10-12, 6:59 pm

How to use HTTP headers to send the hostname of a virtual host on a
server which has no dns ?

I have an apache server on a "home" LAN with several name-based virtual
hosts. They all have the same IP address but each has its own server
name (for example... aaa.home.lan, bbb.home.lan etc.)
I have a local name server which points any local request for
aaa.home.lan or any of the other names to the local server. One of the
virtual servers is the default, so if I point a browser at the raw IP
address it finds the default virtual server.
So far so good.
None of these servers have valid external domain names. So from outside
the home lan I have to point a browser at the raw IP address, which
means I can only get to the default virtual server.
Meanwhile, outside the home lan I have a public website.
From that website I have no trouble accessing the default server on the
home lan using php to redirect eg: <?php header("Location:
http://123.123.123.123" ); ?>
What I want to do is access one of the other virtual servers.
I've been trying to find a way to send the HTTP "Host" header as well as
the IP address so that apache can direct the request to a named virtual
server, instead of the default.
I can't figure out how to do this. Or maybe it's the wrong approach.
Any advice ?
Thanks
Geoff
Geoff

2006-10-12, 6:59 pm


"Geo" <geo@nowhere.com> wrote in message
news:MPG.1f95f672ea5c8dca989680@news.internode.on.net...
> How to use HTTP headers to send the hostname of a virtual host on a
> server which has no dns ?


use the hosts file in your OS ?
i use it to test my vhosts where i have no dns


Frederick Smith

2006-10-12, 6:59 pm

regardless of the right approach ... I dont see too much difficulty in
spending a few dollars on a domain name for the purpose of this exercise.

However, I did the same sort of thing for an unrelated reason, and ran in to
a problem which prevented me from using the domain name at all from a client
on the private network.
I was able to use the default server by using http://hostname , but when I
used www.domain.co.uk - or any of the "virtual" domain names from the
internal network, the DNS returns the public ip address of the ADSL router,
and when this address is used from a client on the private network, the port
forwarding appears not to work, and all I get is the admin web page for the
router.

If I use an external internet connection, the port forwarding / virtual host
thing works just fine - its just that the "test environment" is difficult
to set up. For test purposes, I use a laptop with a modem to dial in from
the outside world - seems to work OK.

On a different tack, somebody suggested to me that the MOD_REWRITE feature
in the webserver might do the trick, but I couldnt make sense of the
documentation ..

I would like to see how this one pans out


Regards


Frederick



"Geo" <geo@nowhere.com> wrote in message
news:MPG.1f95f672ea5c8dca989680@news.internode.on.net...
> How to use HTTP headers to send the hostname of a virtual host on a
> server which has no dns ?
>
> I have an apache server on a "home" LAN with several name-based virtual
> hosts. They all have the same IP address but each has its own server
> name (for example... aaa.home.lan, bbb.home.lan etc.)
> I have a local name server which points any local request for
> aaa.home.lan or any of the other names to the local server. One of the
> virtual servers is the default, so if I point a browser at the raw IP
> address it finds the default virtual server.
> So far so good.
> None of these servers have valid external domain names. So from outside
> the home lan I have to point a browser at the raw IP address, which
> means I can only get to the default virtual server.
> Meanwhile, outside the home lan I have a public website.
> From that website I have no trouble accessing the default server on the
> home lan using php to redirect eg: <?php header("Location:
> http://123.123.123.123" ); ?>
> What I want to do is access one of the other virtual servers.
> I've been trying to find a way to send the HTTP "Host" header as well as
> the IP address so that apache can direct the request to a named virtual
> server, instead of the default.
> I can't figure out how to do this. Or maybe it's the wrong approach.
> Any advice ?
> Thanks
> Geoff



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com