Here's what I ended up doing:
I tried out BaseURLFilter from CherryPy, but for some reason that kept
breaking. It took me a bit to figure it out, but using Kevin's
suggestion (actually, I had to look at cherrypy.request.headerMap-
cherrypy.request.headers is a generator, and I couldn't see how to get
the data I wanted from it. I'm still not used to the idea of
generators. Still, thanks for the help Kevin!), I figured out that
BaseURLFilter was what I wanted- but it was built with Apache in mind.
It turns out that I'm using lighttpd due to a bug in apache that I
couldn't track down on my system. BaseURLFilter uses the
'X-Forwarded-Host' header to try to set the base URL correctly.
Lighttpd doesn't use X-Forwarded-Host, so I had to piece the baseurl
together from other headers it does set. What I ended up doing was
editing
/usr/local/lib/python2.4/site-packages/CherryPy-2.1.0_rc2-py2.4.egg/cherrypy/lib/filter/baseurlfilter.py
and addeing the following:
if cherrypy.config.get('baseUrlFilter.lighttpd', False):
newBaseUrl = request.headerMap.get('X-Forwarded-Proto') +
"://" + request.headerMap.get("X-Host")
Then I just set baseUrlFilter.lighttpd to True in my config and it
started working perfectly.
Anyway, I'm not certain what the right way is to get lighttpd proxy
support put into CherryPy- or whether I should be bugging the lighttpd
folks to add support for the X-Forwarded-Host header to their code. In
the end though, everything is working just fine for me now. Yay.