How to get user's IP in log file with Apache reverse Proxy

Introduction

I use owncloud inside a Docker (image: owncloud/server).

I have a Apache2 reverse proxy to reach the owncloud server with TLS/SSL.
Everything is working pretty well, I can log in, upload/download file, sync my files with my desktop (Linux Mint).

But I would like to use fail2ban and when I check the log file, I only have Proxy's IP address instead of the user's IP address.

I would like to know how to get user's IP in the log file and keep configuration permenent in my docker configurations.

Note: I tried to find solution in this forum but it's mostly for ngix proxy server nothing really specific to Apache2 proxy server.
I tried some solutions randomly and I didn't get good result.

Configurations

The content of apache/virtualhost file:

<VirtualHost *:443>
  ServerName mycloud.myserver.com

  SSLEngine on
  SSLCertificateFile /etc/apache2/mycert.pem
  SSLCertificateKeyFile /etc/apache2/mykey.pem
  SSLCACertificateFile /etc/apache2/my_ca_cert.pem

  ProxyRequests off                                                            

    <Location "/">
      RequestHeader set X-Forwarded-Proto 'https'

      ProxyPreserveHost On
      ProxyPass http://myserver.com:8080/
      ProxyPassReverse http://myserver.com:8080
    </Location>
</VirtualHost>

I used this configuration with and without the RequestHeader setting. And I still have the proxy's IP instead of user's IP.

The docker-compose file

I used "template" provided in the owncloud docker documentation, I only use my personnal parameters.

I didn't set any special extra configurations.

Expected behaviour

When something is logged in the log file, I would like to see the user’s IP address instead of the Proxy’s IP address.

Actual behaviour

I see the Proxy’s IP address everytime.

Server configuration

Operating system:
Ubuntu 22.04

Web server:
Apache2 v2.4.52 (Ubuntu)

ownCloud version:
ownCloud v10.12.0 (inside a docker with image:owncloud/server:lastest)

Conclusion

Your help would be very appreciated to fix that.

Hey,

i think that maybe the ownCloud documentation concerning additional configuration options for trusted proxies could help:

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.