0

I have an Apache 2.4 with PHP 5.4 application using extensive use of SERVER['REMOTE_ADDR'].

The infrastructure is going through changes and recently we deployed an Nginx acting as reverse proxy. The proxy is properly adding X-Real-IP and X-Forwarded-For headers, both showing the real client IP. For portability, we have also containerized both the Apache/PHP application and the Nginx proxy. They are deployed in two different hosts that communicate to each other through external IPs (will be changed to a private network in the future).

I cannot modify the application, but I can modify the Apache configuration.

I have enabled remoteip module, which is a replacement for mod_rpaf. I have tried several configurations such as:

RemoteIPProxiesHeader X-Forwarded-For
RemoteIPInternalProxy <external ip of the proxy>

Or

RemoteIPProxiesHeader X-Forwarded-For
RemoteIPTrustedProxy <external ip of the proxy>

And some combinations of the ~Proxyvariables.

In any case, when running phpinfo() I get the following output:

HTTP_X_REAL_IP          <my real client ip>
HTTP_X_FORWARDED_FOR    <my real client ip>
SERVER_ADDR             <the Apache/PHP docker machine's ip>
REMOTE_ADDR             <external ip of the proxy>

Any idea on how to properly configure the the remoteip module?

0

Seems that the remoteip module shipped with Apache 2.4 doesn't work. I grabbed the last stable version (v0.8.4) of mod_rpaf from Github. Compiled and installed modifying the default configuration as follows:

<IfModule mod_rpaf.c>
  RPAF_Enable       On
  RPAF_ProxyIPs     <external ip of the proxy>
  RPAF_Header       X-Forwarded-For
  RPAF_SetHostName  On
  RPAF_SetHTTPS     On
  RPAF_SetPort      On
</IfModule>

And it worked like charm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.