httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Darroch <>
Subject using X-Forwarded-Host as r->hostname
Date Thu, 03 May 2012 22:57:30 GMT
Hi --

   It's been a remarkably long time since I had anything useful
to commit, and I'm pretty rusty, so I thought I'd throw this out for
discussion as a RTC despite the CTR rules on trunk.  I promise I won't
be offended if anyone says it's a stupid hack and should never be
committed, because, well, it is arguably a very stupid hack.

   I've been fighting a context where I have a new server behind
an ancient internal proxy for some transitional period of time until
we can replace the proxy too.  The proxy won't send Host headers (in
httpd terms, no equivalent to ProxyPreserveHost On functionality), but
it does put the originally requested Host header into X-Forwarded-Host.

   On the backend, try as I might, I could not find a way to map
the X-Forwarded-Host header on top of the Host one prior to the point
where the appropriate <VirtualHost> is determined.  I hoped for
some combo of mod_headers in "early" mode + mod_setenvif, but they
run in post_read_request in the opposite order from what I needed.

   Hence this patch, which adds a UseCanonicalName XHost option in
which X-Forwarded-Host is checked first, and if non-blank, is used
in place of Host to determine the server name.  (The Host header is
left as-is, though.)

   Even if there's a resounding chorus of "boos", perhaps posting it
here will help others facing the same problem in the future find a bit
of a workaround if they're stuck in the same situation.

   Let the torches and firebrands be set alight!  Cheers,


GPG Key ID: 088335A9
GPG Key Fingerprint: 86CD 3297 7493 75BC F820  6715 F54F E648 0883 35A9

View raw message