Skip to content

[BUG] Unban through bwcli when using redis fails #2315

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

Open
2 tasks done
LeVraiRoiDHyrule opened this issue May 24, 2025 · 4 comments
Open
2 tasks done

[BUG] Unban through bwcli when using redis fails #2315

LeVraiRoiDHyrule opened this issue May 24, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@LeVraiRoiDHyrule
Copy link

What happened?

Hi,
I am using redis to persist bans (bw version 1.6.2-rc2). It is configured as such :

      USE_REDIS: yes
      REDIS_HOST: bunkerweb-redis
  bunkerweb-redis:
    image: redis:7-alpine
    container_name: bunkerweb-redis
    restart: unless-stopped
    environment:
      <<: *all-common
    networks:
      - bunkerweb-redis
    volumes:
      - ${CONFIG_FOLDER}/bunkerweb/redis:/data 
    healthcheck:
      test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
      start_period: 20s
      interval: 30s
      retries: 5
      timeout: 3s

bunkerweb-main and bunkerweb-ui are also in the bunkerweb-redis docker network.
Bunkerweb-main does not throw any error when trying to connect to redis at container start. So it is working.

But when I try to do bwcli unban XXXXXXX to unban an ip, I am having the following error:

b87cb053ceb7:~$ bwcli unban XXXXXX
[2025-05-24 12:12:20 +0200] [CLI] [44526] [ℹ️ ] - Getting variables from database
[2025-05-24 12:12:20 +0200] [CLI] [44526] [ℹ️ ] - ✅ Database connection established
[2025-05-24 12:12:21 +0200] [CLI] [44526] [ℹ️ ] - Connecting to Redis at bunkerweb-redis:6379
[2025-05-24 12:12:26 +0200] [CLI] [44526] [❌] - Failed to connect to Redis: Error -3 connecting to bunkerweb-redis:6379. Try again.
[2025-05-24 12:12:26 +0200] [CLI] [44526] [❌] - Failed to connect to Redis, disabling Redis functionality
[2025-05-24 12:12:26 +0200] [API] [44526] [ℹ️ ] - Successfully sent API request to http://bunkerweb-main:5000/unban
[2025-05-24 12:12:26 +0200] [CLI] [44526] [ℹ️ ] - CLI command status : ✔️ (success)

 ✅ SUCCESS 
────────────────────────────────────────────────────────────────────────────────
• 🔓 IP XXXXXX has been unbanned globally
────────────────────────────────────────────────────────────────────────────────

b87cb053ceb7:~$ 

The unban does not work, the ip is still banned.
Would you have an idea why ?

Thanks in advance for any answer.

How to reproduce?

  1. Install bw 1.6.2-rc2
  2. Install redis with the compose above
  3. Configure bw as above
  4. Check that bw connects to redis at startup
  5. Try to unban a banned ip

Configuration file(s) (yaml or .env)

USE_REDIS: yes
      REDIS_HOST: bunkerweb-redis

Relevant log output

b87cb053ceb7:~$ bwcli unban XXXXXX
[2025-05-24 12:12:20 +0200] [CLI] [44526] [ℹ️ ] - Getting variables from database
[2025-05-24 12:12:20 +0200] [CLI] [44526] [ℹ️ ] - ✅ Database connection established
[2025-05-24 12:12:21 +0200] [CLI] [44526] [ℹ️ ] - Connecting to Redis at bunkerweb-redis:6379
[2025-05-24 12:12:26 +0200] [CLI] [44526] [❌] - Failed to connect to Redis: Error -3 connecting to bunkerweb-redis:6379. Try again.
[2025-05-24 12:12:26 +0200] [CLI] [44526] [❌] - Failed to connect to Redis, disabling Redis functionality
[2025-05-24 12:12:26 +0200] [API] [44526] [ℹ️ ] - Successfully sent API request to http://bunkerweb-main:5000/unban
[2025-05-24 12:12:26 +0200] [CLI] [44526] [ℹ️ ] - CLI command status : ✔️ (success)

 ✅ SUCCESS 
────────────────────────────────────────────────────────────────────────────────
• 🔓 IP XXXXXX has been unbanned globally
────────────────────────────────────────────────────────────────────────────────

b87cb053ceb7:~$

BunkerWeb version

1.6.2-rc2

What integration are you using?

Docker

Linux distribution (if applicable)

OpenMediaVault

Removed private data

  • I have removed all private data from the configuration file and the logs

Code of Conduct

  • I agree to follow this project's Code of Conduct
@LeVraiRoiDHyrule LeVraiRoiDHyrule added the bug Something isn't working label May 24, 2025
@TheophileDiot
Copy link
Member

TheophileDiot commented May 26, 2025

Hi @LeVraiRoiDHyrule, thank you for opening this Issue. You have a connection issue with your redis server.

@LeVraiRoiDHyrule
Copy link
Author

Thanks for your answer.
That is the most logical cause. But as I said, the main bunkerweb container can connect to redis without issues when running. I have the following log at start:
025/05/27 09:55:35 [notice] 1064#1064: *18 [REDIS] connectivity with redis server bunkerweb-redis is successful, context: ngx.timer
If I deliberately make the redis connection url false, the logs says that failed to connect. So the connection with redis is working on the main container running.
This connection error to redis only happens when using bwcli. That is why it is weird.

Currently, only my main bunkerweb container can communicate with redis as they are alone in the docker network. Do other containers, like scheduler or autoconf, need to connect to redis too or is all happening through the main container ?

@fl0ppy-d1sk
Copy link
Member

Do you execute bwcli in the BW container ?

@LeVraiRoiDHyrule
Copy link
Author

Yes. But I have just noticed that the error is different if executed in the main bunkerweb container.

bunkerweb-main:

267411e0f622:/usr/share/bunkerweb$ bwcli unban XXXXXX
[2025-05-27 12:52:41 +0200] [CLI] [10553] [ℹ️ ] - Connecting to Redis at bunkerweb-redis:6379
[2025-05-27 12:52:41 +0200] [CLI] [10553] [ℹ️ ] - Successfully connected to Redis
[2025-05-27 12:52:41 +0200] [CLI] [10553] [❌] - Failed to delete ban for 80.83.34.87 from redis
[2025-05-27 12:52:41 +0200] [API] [10553] [❌] - Can't send API request to http://127.0.0.1:5000/unban : Request failed: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
[2025-05-27 12:52:41 +0200] [CLI] [10553] [ℹ️ ] - CLI command status : ✔️ (success)

 ✅ SUCCESS 
────────────────────────────────────────────────────────────────────────────────
• 🔓 IP XXXXX has been unbanned globally
────────────────────────────────────────────────────────────────────────────────

Every other bunkerweb container (bunkerweb-scheduler, bunkerweb-autoconf...):

89617741761c:~$ bwcli unban XXXXX
[2025-05-27 12:53:02 +0200] [CLI] [7527] [ℹ️ ] - Getting variables from database
[2025-05-27 12:53:02 +0200] [CLI] [7527] [ℹ️ ] - ✅ Database connection established
[2025-05-27 12:53:02 +0200] [CLI] [7527] [ℹ️ ] - Connecting to Redis at bunkerweb-redis:6379
[2025-05-27 12:53:07 +0200] [CLI] [7527] [❌] - Failed to connect to Redis: Error -3 connecting to bunkerweb-redis:6379. Try again.
[2025-05-27 12:53:07 +0200] [CLI] [7527] [❌] - Failed to connect to Redis, disabling Redis functionality
[2025-05-27 12:53:07 +0200] [API] [7527] [ℹ️ ] - Successfully sent API request to http://bunkerweb-main:5000/unban
[2025-05-27 12:53:07 +0200] [CLI] [7527] [ℹ️ ] - CLI command status : ✔️ (success)

 ✅ SUCCESS 
────────────────────────────────────────────────────────────────────────────────
• 🔓 IP XXXX has been unbanned globally
────────────────────────────────────────────────────────────────────────────────

So I guess the error message is not being returned when using a container other than bunkerweb-main. There is more details in bunkerweb-main. I still don't understand why it successfully connects while running and disconnects when using bwcli.

I tried deleting redis data and recreating the container, and got the same results. Is there something wrong with my docker compose above ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants