Nginx + apache : REMOTE_ADDR and REMOTE_HOST bug

Jim Ohlstein jim at
Tue Aug 30 23:15:07 UTC 2011

On 8/30/11 5:50 PM, Maxim Dounin wrote:
> Hello!
> On Tue, Aug 30, 2011 at 04:17:52PM -0400, Jim Ohlstein wrote:
>> On 8/30/11 2:29 PM, Albuquerque Rui wrote:
> [...]
>>>>> Changes done, nothing changed.. Still the same problem...The fact is
>>> that it seems mod_rpaf is working well because REMOTE_ADDR is good, but
>>> REMOTE_HOST is not good :( :( :(
>> I agree. It is not resolving the IP incorrectly. It is not an issue with
>> nginx or with mod_rpaf.
> As I wrote in my original reply...
>>>     >     >     I.e. client's ip is correct, but client's hostname still points to
>>>     >     >     your webserver, right?  This looks like problem in mod_rpaf.
> ... this is obviously a problem in mod_rpaf.  It fails to change 
> ip *before* resolving happens in Apache.  (No idea if it's actually 
> possible to implement this correctly though.)

Maxim, we could argue this pedantically all night long and never agree.
However, mod_rpaf is doing exactly what it's designed to do which is to
report the remote IP address correctly. HostNameLookups is *not* a
function of mod_rpaf, it is a function of Apache core.

However... the function works properly in *my* testing as follows.

I created a small php script as follows:


print ('Your IP is "'.$_SERVER['REMOTE_ADDR'].'". ');

print ('Your Host is "'.$_SERVER["REMOTE_HOST"].'".');


I turned on "HostNameLookups" in Apache.

Attached is the result.

This is indeed my IP and host.

Why it's not working for the OP I cannot explain, but it does seem to
work *correctly* as does "HostNameLookups" directive.

> Maxim Dounin
> _______________________________________________
> nginx mailing list
> nginx at

Jim Ohlstein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mod_rpaf.png
Type: image/png
Size: 8715 bytes
Desc: not available
URL: <>

More information about the nginx mailing list