-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
apache image logging client ip address behind reverse proxy #1103
Comments
Hello |
@kissi7 I would really appreciate if you share your working |
@kissi7 disregard, snippet of my working config:
|
Changing the However, the Nextcloud app still does not seem to be obtaining the correct IP from the Nginx reverse proxy that was supplied in the examples folder. I was able to verify this by installing the Restrict login to IP addresses app to try and restrict specific external IPs. However, it does not work as expected. Restricting any external IP addresses will not block their logins. If I were to restrict internal Docker IPs like Is anyone able to help with getting Nextcloud to obtain the correct IPs from the Nginx reverse proxy? I've followed all the instructions (i.e. adding |
@HJunyuan the key concept here is the ability of the reverse proxy (I have tested it with nginx but no luck yet with traefik) to add some headers to the request. In my previous example I'm using I'm afraid you use case it outside the topic of this issue, since you are talking about a plugin which I have no idea about it. Question: are you able to log the header |
@jlegido no worries at all, I think I will raise a new issue on this. As I saw this thread referenced in #570, I just wanted to point out that while the logs will show the correct IP, there is still an issue where the Nextcloud app is not using the correct IP from the header. The plugin I mention merely serves as an example of a case affected by this issue. So to answer your question: Yes, I was able to log the |
@HJunyuan OK, so we narrow down the issue to the plugin, and how it get the public IP address of the request in order to allow or deny it. I agree that makes sense to open a separate issue to track it, good luck |
Hi, I'm experiencing something similar. I get the wrong IP on the Apache logs (the What's wrong with the |
My bad. For some reason Also, I had tu use a custom Dockerfile like this: FROM nextcloud:20.0.4-apache
RUN sed -E -i 's/(LogFormat.+)%h(.+)/\1%a\2/g' /etc/apache2/apache2.conf So Hope it helps. |
If you are going to use %a in your LogFormat directive, be sure mod_remoteip is enabled and you have
In your apache configuration. This does not include any other proxying you might need to configure up-stream. |
For the record, as it's seen here, |
I have the latest docker image from nextcloud (22.1.0-apache), and still i get the nginx proxy ip address on docker logs. The reverse proxy is an nginxproxy/nginx-proxy container. No idea why it does show 172.20.0.3...
|
@Samhamsam Kindly:
If above solution failed:
a) The reverse proxy is sending b) |
FWIW: just changing |
@riyad Thanks a lot for your comment! # Cloudflare IPs: https://www.cloudflare.com/ips/
RemoteIPHeader X-Forwarded-For
RemoteIPTrustedProxy 10.0.0.0/8
RemoteIPTrustedProxy 172.16.0.0/12
RemoteIPTrustedProxy 192.168.0.0/16
RemoteIPTrustedProxy 173.245.48.0/20
RemoteIPTrustedProxy 103.21.244.0/22
RemoteIPTrustedProxy 103.22.200.0/22
RemoteIPTrustedProxy 103.31.4.0/22
RemoteIPTrustedProxy 141.101.64.0/18
RemoteIPTrustedProxy 108.162.192.0/18
RemoteIPTrustedProxy 190.93.240.0/20
RemoteIPTrustedProxy 188.114.96.0/20
RemoteIPTrustedProxy 197.234.240.0/22
RemoteIPTrustedProxy 198.41.128.0/17
RemoteIPTrustedProxy 162.158.0.0/15
RemoteIPTrustedProxy 104.16.0.0/13
RemoteIPTrustedProxy 104.24.0.0/14
RemoteIPTrustedProxy 172.64.0.0/13
RemoteIPTrustedProxy 131.0.72.0/22 And reload the apache within the docker container: To make the change persistent after a docker restart, bind the file from the host or use the COPY cmd inside the |
According to documentation expected behavior is to accept proxy X-FORWARDED-FOR headers from RFC 1918 private IP address ranges. Internally Apache mod_remoteip is used to achieve this. mod_remoteip knows 2 different trusted proxy directives RemoteIPTrustedProxy and RemoteIPInternalProxy. from mod_remoteip
This image defines 3 RFC 1198 ip ranges as RemoteIPTrustedProxy inside Best solution would be to replace RemoteIPTrustedProxy with RemoteIPInternalProxy in /etc/apache2/conf-available/remoteip.conf as previously suggested in #1068. This solution address both Nextcloud logging and Apache logging. For advanced scenario like Cloudflare I would recommend to mount remoteip.conf into the docker host as it's hard or even impossible to configure such using environment variables. This would allow to remove APACHE_DISABLE_REWRITE_IP (and potentially TRUSTED_PROXIES as well). |
Moin,
in remoteip.conf works for me with a Traefik ReverseProxy But what about ipv6 addresses? There again only the local IPv6 IP of the proxy is shown to me in the Docker log: I already tried Any ideas? |
please try this remoteip.conf
|
@isdnfan thanks for the quick reply but unfortunately it did not help |
OK, found a solution for ipv6.
After changing don't forget to restart the docker-daemon, e.g.: Looks like no change (RemoteIPInternalProxy) is needed to apache config. I am a little unsure and hope that this configuration has no disadvantages, especially with regard to stability and security. |
This is still not fixed for me. I just pulled the "latest" image again, and I'm still getting this behavior, making the brute force protection unusable. All I did notice is that the IP in the PR differs from the IP that I see in the logs: |
@UltraBlackLinux As the original issue has been fixed, and your situation is occurring apparently after #2004, please create a dedicated issue with your associated configs. |
Problem:
I'm running docker image
nextcloud:18.0.4-apache
behind a reverse proxy (traefik)
I've setup like this:
the reverse proxy provides correct header "X-Real-IP"
apache2 remoteip is effective
nextcloud.log shows correct client ip address
apache2 log does not show correct client ip address, instead it shows the ip of the reverse proxy
Fix recommendation:
Modify /etc/apache2/apache2.conf to replace the %h with %a in LogFormat, or an equivalent place to override.
LogFormat "%v:%p %a %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i"" vhost_combined
LogFormat "%a %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i"" combined
LogFormat "%a %l %u %t "%r" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
Fix references:
docker-library/wordpress#383 (comment)
https://httpd.apache.org/docs/2.4/mod/mod_remoteip.html
Commit reference:
docker-library/wordpress@a4eef48
The text was updated successfully, but these errors were encountered: