Transportation of a URI Across Port Boundaries for Immoral Purposes

[prev] [thread] [next] [lurker] [Date index for 2006/07/14]

From: Eli Naeher
Subject: Transportation of a URI Across Port Boundaries for Immoral Purposes
Date: 04:15 on 14 Jul 2006
I found this nice little web application I use for keeping track of
random bits of data. It's nothing very fancy but it's clean, simple,
has a nice interface, etc. For some reason, however, its
otherwise-sensible author decided to implement it under Zope, which
needed to be installed to get it going. There were a few
eccentricities involved in doing so (why is the port on which to
listen specified as the combination of a base and an offset? Why do I
need to fill out the HTTP authentication dialog twice to log in?), but
nothing too egregious. So I've been happily using this program locally
for a while.

Today, someone needed to access it from outside the network, and not
wanting to open up random high ports on the firewall for no good
reason, I thought I'd proxy it through Apache and all would be well.

Indeed not. I can get to the opening page, but it turns out that Zope
is serving up absolute links in its HTML, complete with hostname and
port number. Which is pretty ugly, but nothing I haven't seen before.
Even if Zope won't let me convince it to generate relative links like
a civilized application, surely there's a configuration file somewhere
where I can specify the hostname and port number it uses, right?

Ha! No. Apparently this sort of thing is done using a component of
Zope called -- without apparent irony -- the "Virtual Host Monster."
Reading through its documentation evokes that sort of surrealist prose
in which one recognizes all the words but can't be sure whether or not
they're actually intended to mean something when strung together --
however, I did eventually manage to get things working by adding this
to my Apache configuration:

RewriteRule ^/foo/(.*)
http://localhost:9080/VirtualHostBase/http/example.com:80/foo/$1 [L,P]

Yes, that's right -- we're re-writing incoming URIs under /foo/ to
prepend the VirtualHostBase bit, and Zope then parses the resultant
URI it sees from Apache and deduces that it should use
http://example.com:80/foo/ as the base for the links in its response.

--Eli

Generated at 18:01 on 18 Jul 2006 by mariachi 0.52