Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A8663200C45 for ; Tue, 14 Mar 2017 01:22:25 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id A6E6A160B85; Tue, 14 Mar 2017 00:22:25 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id EF4E2160B5D for ; Tue, 14 Mar 2017 01:22:24 +0100 (CET) Received: (qmail 7018 invoked by uid 500); 14 Mar 2017 00:22:23 -0000 Mailing-List: contact modperl-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list modperl@perl.apache.org Received: (qmail 7008 invoked by uid 99); 14 Mar 2017 00:22:23 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Mar 2017 00:22:23 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 9BC07C0118 for ; Tue, 14 Mar 2017 00:22:22 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.498 X-Spam-Level: X-Spam-Status: No, score=0.498 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=rowe-clan-net.20150623.gappssmtp.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 5moUqu7vHv3I for ; Tue, 14 Mar 2017 00:22:21 +0000 (UTC) Received: from mail-io0-f176.google.com (mail-io0-f176.google.com [209.85.223.176]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 528215F397 for ; Tue, 14 Mar 2017 00:22:21 +0000 (UTC) Received: by mail-io0-f176.google.com with SMTP id l7so94873096ioe.3 for ; Mon, 13 Mar 2017 17:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rowe-clan-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=z+xP6UcxHDXKqxd9Af1ZbFDsJpD2Hd2C/0Hk/0KUeBM=; b=L3CQ+zx6In/Tpo1HEZFTU6NmVolzmr8bo70amgFfnSnF90YGih+PEFNxfVNgOVhRKY 1jwSalvCoATBtL4aKwY9xzF/6b6fmUpyY3dzeHexXeK0HYvJmiIPrOYiZTA/+tqVhRIB mYVRFB5sTYYAnKWxNPzEO/AWqFUwkXOAwFmV0WvLcH/vHs6QEK8wHwxlrkzHdP5ae+3R f8dvVD83NeUxmfCwTHqFnk7I8Tj5ZbMyN0gXZKz8zqb7LtdSZDE1WOsNERjy+x6U9WaL sssuGCNI6Jn7+BP/nVmrc853NfMOZFbsMfZ7BFeTgbWdXCYwSCL7XyLQNI/NZUjkdWS6 vdeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=z+xP6UcxHDXKqxd9Af1ZbFDsJpD2Hd2C/0Hk/0KUeBM=; b=Uwrg4mDrYMfGHbKwILiR1KDcD7sxrJvNKn94Hl33vGbcHeHGUIqwytxV1//uKpB1di gbLYqlavNhuyxhRtH2C2UJpJiZlLGPH4pfKY5oCA1X+y+HV/PdKQ6GoF3h2jbreWwSYy yRor0PlBz5TGvBFDeEHpa0Kt9bkcrSqfV3xnyJGmoxYYUfV1QISE8SzdT2hWWKUbGSoe bCGaV0ACUNBrpfxNf+UwZM6sWIrH+ewMbloP3SBPuPFxpX908iZfuV8t/PuUqzlhzC7S TmpLjcfnLvtMk4BrW0ejTjE5HpLk1+Bl5K3GETU7Nm929ApnY+atX2ccN6UT8Sua+FWn RIEw== X-Gm-Message-State: AMke39kFTFOyeC1nTCY+rW2jaQxoLum5PVhVO6P4TH4QgOGdnBntgMjhsu/KqPJrONsa8YRMmtycQabh0NcIhbNC X-Received: by 10.107.186.6 with SMTP id k6mr29158775iof.71.1489449227016; Mon, 13 Mar 2017 16:53:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.55.3 with HTTP; Mon, 13 Mar 2017 16:53:46 -0700 (PDT) In-Reply-To: <1336100174.4826774.1489447711920@mail.yahoo.com> References: <1162631304.1337417.1489118007958.ref@mail.yahoo.com> <1162631304.1337417.1489118007958@mail.yahoo.com> <1336100174.4826774.1489447711920@mail.yahoo.com> From: William A Rowe Jr Date: Mon, 13 Mar 2017 18:53:46 -0500 Message-ID: Subject: Re: Question about Apache 2.4 and libapreq2 (Apache2::Request) To: httpd , modperl@perl.apache.org Cc: JW Content-Type: text/plain; charset=UTF-8 archived-at: Tue, 14 Mar 2017 00:22:25 -0000 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 wrote: > ________________________________ > From: William A Rowe Jr > To: JW > Cc: "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 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!