01-20-04 10:35 AM
>>>>> "KL" == Kyler Laird <Kyler@news.Lairds.org> writes:
KL> Richard E. Silverman <res@qoxp.net> writes:[QUOTE]
KL> Why? Just so that he can turn off the proxying anytime he wants
KL> to go elsewhere? Is it worth it just to avoid configuring the
KL> HTTP server correctly?
A web server using HTTP 1.1 is sensitive to the hostname portion of the
URL, delivered to it via the HTTP "Host" attribute. This is commonly used
to allow a single web server to deliver different content for the same
path depending on the hostname, i.e. "virtual hosting." This works
because the admin can reasonably control what names are available to reach
the server machine, and configure the web server to recognize them.
This breaks down, however, if a client uses some other name unknown to the
server in order to reach it. The server's response in this case is
implementation-dependent; it might just return an error. Apache will
interpret the URL path in the context of the first virtual host defined in
its configuration.
This problem comes up when trying to access a web server via simple SSH
forwarding. To access the forwarded port, the user types in a URL with a
hostname referring to the SSH client (in this case, "localhost", but it
might be anything). But this not only allows the client to make the
connection; the hostname is also delivered as-is to the web server as part
of the request. The server is not generally configured to recognize
"localhost" as one of its virtual web domains, and so something usually
goes wrong -- the poster says he gets the correct "default page," but has
trouble accessing other pages; this is typical of what happens with Apache
in this scenario, where it serves up content from the default virtual
host in response to an unrecognized Host attribute.
KL> Fix the server. There's nothing "incorrect" about what's being
KL> done.
There is no way to "fix the server," in general. The server depends on
receiving correct Host attributes from the client to serve up its various
content trees. It cannot know in advance what name the client might use
in order to access its SSH-forwarded ports. Furthermore, there will
generally only be one of those, whereas there may be several different
virtual hosts whose data the client may want to access. To fix this on
the client side, you would have to arrange for the client's naming service
to map the domain names of the virtual hosts to the IP address of the web
server -- thus wreaking havoc with any other attempts to reach the same
machine using another application or protocol. And the local setup would
have to be frobbed any time new names and virtual hosts are defined on the
server. This approach is fragile and more trouble than it's worth.
The simple way to get correct behavior is to decouple the name used for
accessing the server TCP socket from the name supplied as part of the
URL. Setting the forwarded socket as the browser's HTTP proxy does this.
--
Richard Silverman
res@qoxp.net
[ Post a follow-up to this message ]
|