httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Ruggeri <>
Subject Re: mod_remoteip and mod_http2 combined
Date Sat, 11 Mar 2017 18:57:38 GMT
Thanks, all, for the patience as I finally got back to this.

On 2/24/2017 11:05 AM, Sander Hoentjen wrote:
> On 02/20/2017 07:48 PM, William A Rowe Jr wrote:
>> On Sat, Feb 18, 2017 at 4:25 PM, Daniel Ruggeri <> wrote:
>>> On 2017-02-15 09:07 (-0600), William A Rowe Jr <> wrote:
>>>> On Wed, Feb 15, 2017 at 9:02 AM, Sander Hoentjen <>
>>>>> mod_remote ip has:
>>>>>     /* mod_proxy creates outgoing connections - we don't want those */
>>>>>     if (!remoteip_is_server_port(c->local_addr->port)) {
>>>>>         return DECLINED;
>>>>>     }
>>>>> I am guessing something similar is needed for h2 connections?
>>>> I suspect that the mod_remoteip logic is wrong, that it should be guarding
>>>> against any subordinate connections and examining only explicitly configured
>>>> ports / origin IPs. the PROXY protocol is not part of the HTTP protocol and
>>>> incompatible with it, so the trust list logic isn't directly compatible (this
>>>> clearly explained in the PROXY pseudo-RFC.)
>>> Hi, Bill. That is what the module is doing. The original authors wrote it to
have a list of virtual hosts it is explicitly enabled for and explicitly disabled for. I added
a third list for optional vhosts. In the pre_connection hook, it checks to see if the connection's
local_addr (which should normally be the server's IP) is explicitly configured to enable PROXY
handling. It then checks to see if the local port is a server port.
>>> Looking at the logs shared, is the server IP:Port combo and
is also the local IP:Port from mod_h2. If h2 sets the master of this connection, then we could
skip the whole ordeal with this patch:
>>> Index: modules/metadata/mod_remoteip.c
>>> ===================================================================
>>> --- modules/metadata/mod_remoteip.c     (revision 1781701)
>>> +++ modules/metadata/mod_remoteip.c     (working copy)
>>> @@ -862,6 +862,10 @@
>>>      remoteip_conn_config_t *conn_conf;
>>>      int optional;
>>> +    if (c->master != NULL) {
>>> +        return DECLINED;
>>> +    }
>>> +
>>>      conf = ap_get_module_config(ap_server_conf->module_config,
>>>                                  &remoteip_module);
>>> .. but I don't know if that potentially means we are looking at the wrong connection.
> First I'll say that with the "Optional" mode it worked, just not with On
> I just tried this patch and as far as I have tested this seems to work
> fine in On mode, as well as in Optional. I do see some other issue, but
> that is probably in my own code, I'll try to track that down later.

This is good news and about what I was expecting to happen. I will add
this to the commit I've got coming that incorporates a lot of Ruediger's

>> That should be close, but need to ensure c->master is initialized for
>> http as well
>> where there is no master/subordinate.
> I am not sure what this means, how should I test this?

Hi, Bill - also hoping for a bit more input. Since PROXY protocol is not
tied to any particular layer 7 protocol, I don't think we'd have to
verify it is initialized for HTTP - just that there is no master at all.
At least, that's my understanding so I appreciate any corrections.

>> If the 'optional' (unwise) feature were removed, the decision to
>> inject the filter before
>> the http or h2 filter would be trivial, it would step out of the way
>> after the first-pass
>> (and perhaps not need to live on the filter stack at all - if we do a
>> fixed read against
>> the core filter - we hopefully know the number of bytes affected early
>> and can then
>> do a second read to complete the v1 vs v2 read?) --- all before we are
>> in a multiple
>> pipeline state.

I don't think that is the case because the module was also written to
support PROXY header consumption in a name-based virtual host context,
too, where ServerName abc may require it but ServerName xyz does not.
Agreed, if it were simply all or nothing (either it's enabled on this
connection or not), we could avoid some of these gymnastics but I think
that use case as well as the Optional use case requires it.

>> If we move to a conn_rec oriented one-shot nothing happens during the request
>> phase at all.
>> By looking at the protocol filter stack, we should be able to glean
>> whether we are
>> talking to the core filter, or an 'unexpected' non-network filter, right?
> I myself have no use-case at the moment for the "Optional" mode, maybe
> others do.

Sure, to clarify, the Optional use case came from a member on one of our
cousin projects (Tomcat) Chris Schultz as well as my own use cases. It
is useful for internally accessing the site from behind the
loadbalancer. When there is a publicly addressed upstream loadbalancer
(Amazon ELB or just HAProxy itself) talking to RFC1918 addressed or
non-routeable backend httpd servers, it becomes impossible to enable
internal communication on the RFC1918 space to the backend instances.
If the goal is to monitor or probe the site and (httpd proxy) backends
internally for health, this *can* be done by duplicating the virtual
hosts. Depending on the complexity of the virtual hosts, what resources
those virtual hosts have (proxies and whatnot) and their general size,
this could result in a fairly unmanageable httpd configuration having a
vhost that requires PROXY header and a second one on a different port or
IP that does not.
It gets even more complicated when you are aiming to do management
tasks. If you have balancers configured at the vhost as intended, you
can only manage those balancers from the vhost they live in. Further,
you may want to view server statistics, check info about the ldap cache,
etc but permit access to those things only from a trusted network in
addition to the user credentials protecting it.
So for those examples, aside from creating an internal HAProxy to
provide the header, it's not really possible to access the site
internally when "On". With "Optional" it's possible to keep the same
number of vhosts and enable the various management handlers and restrict
them to the RFC1918 space (plus any other authnz mechanisms). The other
obvious option would be to enable those handlers to the public Internet,
but that's bad juju :-)

Daniel Ruggeri

View raw message