I'm running Apache behind an Nginx reverse proxy and want to show the original source IPs of the requests in Apache's logs using the remoteip module.

The official standard header for passing that information from Nginx to Apache is Forwarded. However, Forwarded contains additional information aside from the original IP itself, in contrast to the common (but non-standard) X-Forward-For. It seems that this causes problems for remoteip.

Using the following Apache configuration

RemoteIPHeader Forwarded
LogFormat "%a <Forwarded: %{Forwarded}i>" forwarded
CustomLog /var/log/apache2/forwarded.log forwarded

my log entries look like this: <Forwarded: for=; host=my-host:443; proto=https>

That is, %a is not updated to the original IP, even though the Forwarded header is present.

If I configure my reverse proxy to pass just the IP using the X-Forwarded-For header and configure remoteip to use that field instead then everything works as expected.

However, I'd prefer to use the header recommended by the standard -- is there a way to do this?

I'm using Apache 2.4.10.


The Forwarded header is currently not supported by remoteip. See this ticket in Apache's issue tracker.

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.