Re: Question about Apache 2.4 and libapreq2 (Apache2::Request)

2017-03-13 Thread JW

Don't know the answer to your question about remoteip ...
However, what I noted is that the Apache remoteip module, 
when configured with "RemoteIPHeader X-Forwarded-For", deletes the 
X-Forwarded-For header. 
In the PerlPostReadRequestHandler stage, the X-Forwarded-For headerexists and 
it seems Apache has yet to use the X-Forwarded-For value as
 $r->useragent_ip gives 127.0.0.1.
In the next stage, PerlTransHandler, a call to $r->useragent_ip() gives the 
correct remote ip, but the X-Forwarded-For header is no longer available. 


  From: William A Rowe Jr <wr...@rowe-clan.net>
 To: httpd <d...@httpd.apache.org>; modperl@perl.apache.org 
Cc: JW <gav...@yahoo.com>
 Sent: Monday, March 13, 2017 4:53 PM
 Subject: Re: Question about Apache 2.4 and libapreq2 (Apache2::Request)
   
This has occurred in multiple contexts, including throwing segfaults in the
modperl test framework (connection handler, so no req_rec.)

Wondering if remoteip might be able to run a little bit earlier? This is all
relevant to what we are discussing about PROXY protocol enhancements.

On Mon, Mar 13, 2017 at 6:28 PM, JW <gav...@yahoo.com> wrote:
> 
> From: William A Rowe Jr <wr...@rowe-clan.net>
> To: JW <gav...@yahoo.com>
> Cc: "modperl@perl.apache.org" <modperl@perl.apache.org>
> Sent: Friday, March 10, 2017 1:44 PM
> Subject: Re: Question about Apache 2.4 and libapreq2 (Apache2::Request)
>
> On Thu, Mar 9, 2017 at 9:53 PM, JW <gav...@yahoo.com> wrote:
>>
>> It's been over a month since moving to Apache 2.4. It was fairly
>> straightforward and required
>> little code to be updated, most of it Apache config. Everything runs as it
>> did before the update and I've
>> had no problems. The one function that didn't 'work' is described below.
>>
>> This mod_perl server is behind a proxy on the same machine. Under Apache
>> 2.2, $r->remote_ip()
>> returned 127.0.0.1 and not the user's actual IP.  So, a
>> PerlPostReadRequestHandler extracted the user's
>> IP address from the X-Forwarded-For header and set it with $r->remote_ip(
>> $ip ).
>>
>> In Apache 2.4 (and mod_perl now) $c->remote_ip is split into
>> $r->useragent_ip and $c->client_ip:
>> http://httpd.apache.org/docs/2.4/developer/new_api_2_4.html
>> But, $r->useragent_ip (wrongly) gives me 127.0.0.1. Perhaps this'll be
>> fixed
>> at some point (unless
>> I'm doing something wrong). So, for now, as above, the IP is extracted
>> from
>> X-Forwarded-For
>> and set with $r->useragent_ip( $ip ).
>
>
> Keep in mind you can't use r->useragent_ip until the request is created,
> e.g.
> the create request hook is not a good place to try this (we actually had to
> work around a crash related to this behavior in httpd's sources.) After the
> read_request phase, this information will be finalized (provided that the
> mod_remoteip config is correct).
>
> It seems some code was expecting to read the useragent_ip in a very early
> phase of connection handling, although the headers to populate it for the
> request had not even been read off the wire :) So now, all attempts to read
> this too-early will result in the c->client_ip values.
>
> Here's when the action happens;
> ap_hook_post_read_request(remoteip_modify_request, NULL, NULL,
> APR_HOOK_FIRST);

Yes, it seems PerlPostReadRequestHandler was too early. $r->useragent_ip()
gives the remote ip with the PerlTransHandler and later stages. Thanks!


   

Re: Question about Apache 2.4 and libapreq2 (Apache2::Request)

2017-03-09 Thread JW
Hi,
Back in January I was planning on moving to Apache 2.4+mod_perl+libapreq2 
from Apache 2.2+mod_perl+libapreq2. I'd asked if anyone had problems doing a 
similar
move -- the answer was no. Thank you again to everyone who replied my earlier 
post.  

It's been over a month since moving to Apache 2.4. It was fairly 
straightforward and requiredlittle code to be updated, most of it Apache 
config. Everything runs as it did before the update and I've 
had no problems. The one function that didn't 'work' is described below. 

This mod_perl server is behind a proxy on the same machine. Under Apache 2.2, 
$r->remote_ip() 
returned 127.0.0.1 and not the user's actual IP.  So, a 
PerlPostReadRequestHandler extracted the user's 
IP address from the X-Forwarded-For header and set it with $r->remote_ip( $ip ).

In Apache 2.4 (and mod_perl now) $c->remote_ip is split into $r->useragent_ip 
and $c->client_ip:
http://httpd.apache.org/docs/2.4/developer/new_api_2_4.html 
But, $r->useragent_ip (wrongly) gives me 127.0.0.1. Perhaps this'll be fixed at 
some point (unlessI'm doing something wrong). So, for now, as above, the IP is 
extracted from X-Forwarded-For 
and set with $r->useragent_ip( $ip ). 

I was asked by one of the earlier responders to share my experience with the 
move to Apache 2.4,in case there were others in the same boat. So, if there 
are, jump right in and good luck!
Cheers,
John














Re: Question about Apache 2.4 and libapreq2 (Apache2::Request)

2017-01-20 Thread JW


 
On Wed, 18 Jan 2017 20:06:41 + (UTC)
JW <gav...@yahoo.com> wrote:

>  before I make a permanent switch to Apache 2.4, I was wondering if anyone 
>doing a similar upgrade experienced problems using libapreq2 and what 
>alternative(s) they chose. 
> 

You are more likely to encounter problems with Apache than libapreq. 

They changed quite a few things, notably the 'Allow from all' and 'Deny from 
all' directives, replaced by 'Require all granted/denied', that you have to 
modify for all your sites; I was also affected by a change in the running order 
of filters (mod_deflate ran before my custom outputfilter in 2.4).

Everything running smoothly since those were fixed across several different 
virtual hosts.



-- 
                    Bien à vous, Vincent Veyron 

https://marica.fr/ 
Logiciel de suivi des contentieux juridiques, des sinistres d'assurance et des 
contrats

Vincent,Thanks for the information, will keep those points in mind when I make 
the switch. Happy to hear your move to 2.4 has been successful. 

Cheers,John







   

Question about Apache 2.4 and libapreq2 (Apache2::Request)

2017-01-18 Thread JW

Hi,

I currently use Apache 2.2, mod_perl and libapreq2 (for Apache2::Request and 
Apache2::Cookie). I did a test installation of Apache 2.4 (yum), mod_perl 
(source) and libapreq2-2.13 (source). and it seems to work fine. 

The last update of libapreq2 was in 2010. I'm aware that not every library has 
to be updated and frankly I'm pleased that it still works. However, before I 
make a permanent switch to Apache 2.4, I was wondering if anyone doing a 
similar upgrade experienced problems using libapreq2 and what alternative(s) 
they chose. 

Thank you. 

John