Open cyril-bouthors opened 9 years ago
Hello Cyril,
Did you try to replace the LogFormat "%h" value with "%a" ?
Hi @nfillot,
I replaced %h
with %a
in all the LogFormat
default directives and the IP address is correctly shown in the error log, the access log and the server-status.
I think it's better if mod_rpaf works with the default LogFormat
value as it used to be working in previous releases.
Is there a way to avoid this regression?
Thanks.
That would be nice indeed.
Can you please verify the headers being passed from the reverse proxy? Your configuration for mod_rpaf doesnt explicity set it via RPAF_Header
, perhaps you are using a different header.
My config:
RPAF_Enable On RPAF_ProxyIPs X.X.X.X (proxy server) RPAF_Header X-Forwarded-For
pcap'ed traffic on backend, traffic from X.X.X.X(proxy server):
X-Forwarded-For: Y.Y.Y.Y (my computer)
This is apache2.4 from debian jessie: https://packages.debian.org/jessie/apache2 Latest rpaf version 0.8.5-rc1 from github My client IP appears in $_SERVER['REMOTE_ADDR'] using php5-fpm+mod fastcgi, which is correct However the log appearing in apache logs, using the default logformat, is the proxy server IP
The funny thing is that i tried the latest version from here because i had the exact opposite result with the rpaf 0.6 version in Jessie, incorrect IP (proxy server ip) in php, and correct IP in logs (probably related to the ticket you got a few weeks ago:) https://github.com/gnif/mod_rpaf/issues/33
Rpaf from jessie is here: https://packages.debian.org/jessie/libapache2-mod-rpaf
Is that %a or %h in the log config? (Both from memory, hope it makes sense)
It's %h in apache2.conf, at least in debian Jessie.
And using %a shows the correct IP (client IP Y.Y.Y.Y).
We have the same problen (in 0.8.4). %a is working, but %h is the proxy ip.
I seriously think now it is perfect like this, before there was no way to keep both the Proxy IP and the Client IP. Though the change was surprising, maybe it could be more documented.
Thank you!
i think this is regression, can there be added perhaps separate option to control this?
as changing log format in all vhosts and installations can be problematic, can surely still miss some place.
for reference adding doc what %a
and %h
mean:
Format String | Description |
---|---|
%a | Client IP address of the request (see the mod_remoteip module). |
%h | Remote hostname. Will log the IP address if HostnameLookups is set to Off, which is the default. If it logs the hostname for only a few hosts, you probably have access control directives mentioning them by name. See the Require host documentation. |
http://httpd.apache.org/docs/current/mod/mod_log_config.html#formats
ps: i tested that with php $_SERVER['REMOTE_ADDR']
and require ip x.y.z.z
work properly :+1:
if there's no plan to fix the %h
value from mod_rpaf
side, this should be described in release notes and readme that must configure LogFormat
tested mod_remoteip and seems behave identical to mod_rpaf
:
LoadModule remoteip_module modules/mod_remoteip.so
RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 127.0.0.1
%h
prints ip from connection and only %a
contains the client real ip
@gnif ping. please see discussion and my notes. what's your verdict?
This is not a viable fix for this, there is an issue with mod_rpaf as it is intended to make the reverse proxy transparent, there should be no need to reconfigure any logging. I will investigate this when I find some time.
Also keep in mind that the Apache API changed in 2.4 to separate the client and connection/peer address. If historically %h
was the connection IP and %a
is a 2.4 addition, I don't know whether we need to fix this. If we did, how could I get the proxies IP address?
Behaving similar to mod_remoteip
in this regard is a good thing IMO. And still, mod_remoteip
cannot transparently handle SSL termination (which can happen on Amazon EC2 ELBs, for example).
After an upgrade from 0.6 to 0.8.4, the IP address is no longer correctly defined in the Apache access logs but is still correct in ErrorLog file and the
server-status
page: the IP address of the proxy is shown in the access logs, instead.I'm running Debian/jessie with Apache 2.4.10-10 and can reproduce the issue on two distinct machines, both running the same environment.
mod_rpaf configuration:
Apache logs configuration:
Logs extract (10.10.0.254 is the client IP address and 127.0.0.1 is the proxy):
server-status
page: