Skip to content
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

Log of unsuccessful login attempts with external IP #3224

Open
tonitonae opened this issue Oct 13, 2020 · 12 comments · Fixed by #3226
Open

Log of unsuccessful login attempts with external IP #3224

tonitonae opened this issue Oct 13, 2020 · 12 comments · Fixed by #3226

Comments

@tonitonae
Copy link
Contributor

Hi.

I was trying to configure fail2ban with FreshRSS running in a Docker container and I have several issues.

First one: is there any global log that can be accessed from outside the container to be processed by a fail2ban instance? As far as I can see, there is only a per user log in the data foder, but there I can not find the 403 lines that are being registered with the offending IP.

Second one: Regarding the IP, in mi instance, what I see is the local IP, not the external one, which is the one that must be blocked if several attempts to login fail. Would it be possible to log the external IP from which the container is being accessed? I am running the container with an isolated bridge network as recommended in the docs.

Thanks in advance for your help.

@Alkarex Alkarex added this to the 1.18.0 milestone Oct 13, 2020
@Alkarex
Copy link
Member

Alkarex commented Oct 13, 2020

When using the official FreshRSS Docker image, there is a copy of the logs in the normal Docker logs:

docker logs -f freshrss

You are correct that the IP logged there is the one coming from the proxy. I will fix that.

@tonitonae
Copy link
Contributor Author

When using the official FreshRSS Docker image, there is a copy of the logs in the normal Docker logs:

docker logs -f freshrss

Yes, I know about the normal Docker logs. What I meant is if it is possible to access those logs through a file, stored in a folder that could be mapped to a shared folder in the host. This way, the fail2ban instance could constantly monitor the log file and block offending IPs without delay. Would this be possible withouth manually modifying the container (this complicates updating whenever a new version is released).

You are correct that the IP logged there is the one coming from the proxy. I will fix that.

Thanks!

Alkarex added a commit to Alkarex/FreshRSS that referenced this issue Oct 14, 2020
@Alkarex
Copy link
Member

Alkarex commented Oct 14, 2020

Logging the proper IP should be fixed in #3226
Regarding accessing the logs from the host, have you seen other Docker images proposing something smart?
You can always access the Docker logs locally (simple JSON files):

tail /var/lib/docker/containers/`docker inspect --format="{{.Id}}" freshrss`/`docker inspect --format="{{.Id}}" freshrss`-json.log | jq -r .log

@tonitonae
Copy link
Contributor Author

Logging the proper IP should be fixed in #3226

I will look into it and report back. Thanks.

Regarding accessing the logs from the host, have you seen other Docker images proposing something smart?
You can always access the Docker logs locally (simple JSON files):

tail /var/lib/docker/containers/`docker inspect --format="{{.Id}}" freshrss`/`docker inspect --format="{{.Id}}" freshrss`-json.log | jq -r .log

In other images what I see is that the log is also written to a file, which can be exposed in a volume mounted from the host. This way, that volume (or, at least, the file) can be monitored by the instance running fail2ban.

Would it be possible to write the log both to stdout (redirected to Docker) and also to a file? Something similar to what the tee UNIX command does...

@Alkarex
Copy link
Member

Alkarex commented Oct 15, 2020

Isn't my suggestion higher up to read the file produced by Docker log usable? It is just a file on your host.

@tonitonae
Copy link
Contributor Author

The thing is that fail2ban monitors files. Thus, we would need to configure something in the host to extract the logs from Docker into a file. I think that this is not an ideal solution as a periodic job should be configured, which necessarily will introduce a delay in the moment the IP gets banned.

Or maybe there is another alternative of which I am not aware?

Alkarex added a commit that referenced this issue Oct 16, 2020
@Alkarex
Copy link
Member

Alkarex commented Oct 16, 2020

@tonitonae The Docker log is a normal text file (though in JSON format by default).

However, you can also add additional logging this way:

  1. Specify what additional log you want in a local /example/log.conf
LogFormat "%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined_ip
CustomLog /var/log/apache2/freshrss.log combined_ip
  1. Mount this file in your Docker run or docker-compose:
-v /example/log.conf:/etc/apache2/conf-enabled/log.conf
  1. Mount your extra log as well:
-v /var/log/apache2/freshrss.log:/var/log/apache2/freshrss.log
  1. Access your local log:
tail /var/log/apache2/freshrss.log

(Remember log-rotate)

@Alkarex Alkarex reopened this Oct 16, 2020
@Alkarex
Copy link
Member

Alkarex commented Oct 16, 2020

If that works for you, could you please add it in our documentation, maybe as a new fail2ban section in https://github.com/FreshRSS/FreshRSS/blob/master/docs/en/admins/09_AccessControl.md

@Alkarex Alkarex modified the milestones: 1.18.0, 1.19.0 Mar 14, 2021
@Alkarex Alkarex modified the milestones: 1.19.0, 1.20.0 Oct 29, 2021
@Alkarex Alkarex modified the milestones: 1.20.0, 1.21.0 May 7, 2022
@math-GH
Copy link
Contributor

math-GH commented Aug 28, 2022

@tonitonae could you please support us here with a PR to improve our documentation with your knowledge/experience?

@tonitonae
Copy link
Contributor Author

Hi @math-GH.

Sure thing, but I do not think I can do it immediately. I am a bit overwhelmed with work and some personal affairs. I will add this to my ToDo list, but no guarantees that I can do it in the following weeks.

Sorry about that :/

@math-GH
Copy link
Contributor

math-GH commented Sep 5, 2022

There is no hurry

@Alkarex Alkarex modified the milestones: 1.21.0, 1.22.0 Jan 9, 2023
@Alkarex Alkarex removed this from the 1.22.0 milestone Jun 16, 2023
@Alkarex Alkarex added this to the 1.23.0 milestone Jun 16, 2023
@Alkarex Alkarex modified the milestones: 1.23.0, 1.22.0 Jul 3, 2023
@Alkarex
Copy link
Member

Alkarex commented Jul 26, 2023

Reworked in #5549
Tests welcome

@Alkarex Alkarex modified the milestones: 1.22.0, 1.23.0 Oct 23, 2023
@Alkarex Alkarex modified the milestones: 1.23.0, 1.24.0 Nov 24, 2023
@Alkarex Alkarex modified the milestones: 1.24.0, 1.25.0 Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants