httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Darroch <>
Subject Re: using X-Forwarded-Host as r->hostname
Date Sat, 12 May 2012 00:30:01 GMT
William A. Rowe Jr. wrote:

> On 5/3/2012 6:14 PM, Igor Gali? wrote:

>> Wouldn't it be more appropriate to hack up^W^Wexpand mod_remoteip?
> That answer seems sensible to me, too.

   Thanks, guys, for pointing me at mod_remoteip; I agree it's a more
logical place for this kind of thing.

   The challenge for me personally is that in ap_read_request(),
ap_update_vhost_from_headers() is called before
ap_run_post_read_request().  So even the first-out-of-the-gate
behaviour of mod_remoteip, which uses APR_HOOK_FIRST in post_read_request,
is too late because the choice of <VirtualHost> has already been made.
That's why I ended up with a hack on UseCanonicalName instead of something
more obviously module-based.

   If others can find a tidier solution for that (or prove me wrong --
I didn't spend ages tracing the control flow), that would be great.

   In the meantime I uploaded a further hack, which borrows some of
the nice logic in mod_remoteip for handling multiple values in the
X-Forwarded-Host header.

> That describes your use case, but let's presume this behavior doesn't use
> a consistent header name.  UseCanonicalName On|Off|{header-name} seems much
> more appropriate.
> What is the fallback for missing {header-name} values?  On, or off?  How would
> we make this configurable?

   Hmm.  Looking at the code in mod_remoteip, it would perhaps be
useful to align better with that module's directives (RemoteHostHeader,

   One of the several things I'm uncertain about, though,
is how to distinguish the case of just wanting to override, say,
the Host header *after* the <VirtualHost> has been selected (perhaps
this is the default case, to work like RemoteIPHeader), from the
"extra" case of using the inserted new value before <VirtualHost>
selection, which is more in UseCanonicalHost's territory.

   Thoughts, anyone?  And thanks very much for the feedback!


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

View raw message