bunkerity / bunkerweb

🛡️ Open-source and next-generation Web Application Firewall (WAF)
https://www.bunkerweb.io
GNU Affero General Public License v3.0
6.5k stars 363 forks source link

[BUG] Docker-Compose setup #1466

Closed alwinhb closed 2 weeks ago

alwinhb commented 1 month ago

What happened?

I am trying to setup the complete stack using docker-compose, I have added my compose.yaml

Kindly guide/suggest if my compose file is ok or needs to be updated.

How to reproduce?

docker-compose up

Configuration file(s) (yaml or .env)

version: "3.5"

services:
  bunkerweb:
    image: bunkerity/bunkerweb:1.5.9
    ports:
      - 80:8080
      - 443:8443
    labels:
      - "bunkerweb.INSTANCE=yes"
    environment:
      - SERVER_NAME=www.example.com
      - API_WHITELIST_IP=127.0.0.0/8 10.20.30.0/24
    networks:
      - bw-universe
      - bw-services

  bw-scheduler:
    image: bunkerity/bunkerweb-scheduler:1.5.9
    depends_on:
      - bunkerweb
      - bw-docker
    volumes:
      - bw-data:/data
    environment:
      - DOCKER_HOST=tcp://bw-docker:2375
    networks:
      - bw-universe
      - bw-docker

  bw-docker:
    image: tecnativa/docker-socket-proxy:nightly
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      - CONTAINERS=1
      - LOG_LEVEL=warning
    networks:
      - bw-docker

volumes:
  bw-data:

networks:
  bw-universe:
    name: bw-universe
    ipam:
      driver: default
      config:
        - subnet: 10.20.30.0/24
  bw-services:
    name: bw-services
  bw-docker:
    name: bw-docker

Relevant log output

bunker_waf-bw-scheduler-1  | Traceback (most recent call last):
bunker_waf-bw-scheduler-1  |   File "/usr/local/lib/python3.12/pathlib.py", line 1311, in mkdir
bunker_waf-bw-scheduler-1  |     os.mkdir(self, mode)
bunker_waf-bw-scheduler-1  | FileExistsError: [Errno 17] File exists: '/var/cache/bunkerweb'
bunker_waf-bw-scheduler-1  | 
bunker_waf-bw-scheduler-1  | During handling of the above exception, another exception occurred:
bunker_waf-bw-scheduler-1  | 
bunker_waf-bw-scheduler-1  | Traceback (most recent call last):
bunker_waf-bw-scheduler-1  |   File "/usr/share/bunkerweb/scheduler/main.py", line 41, in <module>
bunker_waf-bw-scheduler-1  | 
bunker_waf-bw-scheduler-1  |     CACHE_PATH.mkdir(parents=True, exist_ok=True)
bunker_waf-bw-scheduler-1  |   File "/usr/local/lib/python3.12/pathlib.py", line 1320, in mkdir
bunker_waf-bw-scheduler-1  |     if not exist_ok or not self.is_dir():
bunker_waf-bw-scheduler-1  |                            ^^^^^^^^^^^^^
bunker_waf-bw-scheduler-1  |   File "/usr/local/lib/python3.12/pathlib.py", line 875, in is_dir
bunker_waf-bw-scheduler-1  |     return S_ISDIR(self.stat().st_mode)
bunker_waf-bw-scheduler-1  |                    ^^^^^^^^^^^
bunker_waf-bw-scheduler-1  |   File "/usr/local/lib/python3.12/pathlib.py", line 840, in stat
bunker_waf-bw-scheduler-1  |     return os.stat(self, follow_symlinks=follow_symlinks)
bunker_waf-bw-scheduler-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bunker_waf-bw-scheduler-1  | PermissionError: [Errno 13] Permission denied: '/var/cache/bunkerweb'
bunker_waf-bw-scheduler-1  | [2024-09-10 10:58:52] - ENTRYPOINT - ℹ️  - Scheduler stopped

BunkerWeb version

1.5.9

What integration are you using?

Docker

Linux distribution (if applicable)

No response

Removed private data

Code of Conduct

cocoonkid commented 1 month ago

I had the same issue.

just stop the services and delete the bunkerweb volume.

Then restart them.

It will regenerate all your certs and start from scratch but it will work.

alwinhb commented 1 month ago

I still get this error Access denied for user 'bunkerweb'@'{MY_IP_ADD}

Can you add your compose file?

@cocoonkid

@ff6347 @adren @FacundoAcevedo

fl0ppy-d1sk commented 1 month ago

Hello @alwinhb,

Can you try docker compose down -v before starting the stack ? (-v is important)

alwinhb commented 1 month ago

@fl0ppy-d1sk Thanks it worked

Now as i go to http://localhost:7000

As i add the admin username and password, I see this error Wrong CSRF token !

Also I tried using http://localhost:7000/setup but it routes again to http://localhost:7000/login

Can you guide on this error

@ff6347 @adren @FacundoAcevedo

TheophileDiot commented 2 weeks ago

Hi @alwinhb, sorry for the late response. Did you have a look at this ? https://docs.bunkerweb.io/latest/web-ui/#advanced-installation

alwinhb commented 2 weeks ago

@TheophileDiot I am unable to see login page using the compose yaml available at this link.

I get 403 error using below yaml

version: "3.5"

services:
  bunkerweb:
    image: bunkerity/bunkerweb:1.5.10
    ports:
      - 80:8080
      - 443:8443
    labels:
      - "bunkerweb.INSTANCE=yes"
    environment:
      - SERVER_NAME=www.example.com
      - MULTISITE=yes
      - DATABASE_URI=mariadb+pymysql://bunkerweb:changeme@bw-db:3306/db # Remember to set a stronger password for the database
      - API_WHITELIST_IP=127.0.0.0/8 10.20.30.0/24
      - DISABLE_DEFAULT_SERVER=yes
      - USE_CLIENT_CACHE=yes
      - USE_GZIP=yes
      - www.example.com_USE_UI=yes
      - www.example.com_USE_REVERSE_PROXY=yes
      - www.example.com_REVERSE_PROXY_URL=/changeme
      - www.example.com_REVERSE_PROXY_HOST=http://bw-ui:7000
      - www.example.com_INTERCEPTED_ERROR_CODES=400 404 405 413 429 500 501 502 503 504
      - www.example.com_MAX_CLIENT_SIZE=50m
    networks:
      - bw-universe
      - bw-services

  bw-scheduler:
    image: bunkerity/bunkerweb-scheduler:1.5.10
    depends_on:
      - bunkerweb
      - bw-docker
    environment:
      - DATABASE_URI=mariadb+pymysql://bunkerweb:changeme@bw-db:3306/db # Remember to set a stronger password for the database
      - DOCKER_HOST=tcp://bw-docker:2375
    networks:
      - bw-universe
      - bw-docker

  bw-docker:
    image: tecnativa/docker-socket-proxy:nightly
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      - CONTAINERS=1
      - LOG_LEVEL=warning
    networks:
      - bw-docker

  bw-ui:
    image: bunkerity/bunkerweb-ui:1.5.10
    depends_on:
      - bw-docker
    environment:
      - DATABASE_URI=mariadb+pymysql://bunkerweb:changeme@bw-db:3306/db # Remember to set a stronger password for the database
      - DOCKER_HOST=tcp://bw-docker:2375
      - ADMIN_USERNAME=changeme
      - ADMIN_PASSWORD=changeme # Remember to set a stronger password for the changeme user
    networks:
      - bw-universe
      - bw-docker

  bw-db:
    image: mariadb:10.10
    environment:
      - MYSQL_RANDOM_ROOT_PASSWORD=yes
      - MYSQL_DATABASE=db
      - MYSQL_USER=bunkerweb
      - MYSQL_PASSWORD=changeme # Remember to set a stronger password for the database
    volumes:
      - bw-data:/var/lib/mysql
    networks:
      - bw-docker

volumes:
  bw-data:

networks:
  bw-universe:
    name: bw-universe
    ipam:
      driver: default
      config:
        - subnet: 10.20.30.0/24
  bw-services:
    name: bw-services
  bw-docker:
    name: bw-docker
TheophileDiot commented 2 weeks ago

@alwinhb how do you access the web UI ?

alwinhb commented 2 weeks ago

@TheophileDiot localhost:8080

Little change in my docker compose

   ports:
      - 8080:8080
      - 443:8443
TheophileDiot commented 2 weeks ago

Do you try to access it via https://your-ip-address-or-fqdn/changeme ?

alwinhb commented 2 weeks ago

Yeah and I get - Access is forbidden to the requested page

@TheophileDiot

TheophileDiot commented 2 weeks ago

@alwinhb Did you edit your hosts file by adding this entry ?

127.0.0.1 www.example.com

If not that's the issue, you should be able to access the web UI via https://www.example.com/changeme afterward

alwinhb commented 2 weeks ago

@TheophileDiot - This issue is resolved - "Access is forbidden now",

But now I get a blank page with text - "Nothing to see here"

I want to setup and add my configurations but I don't see setup page with /setup.

TheophileDiot commented 2 weeks ago

@alwinhb if you want to use the setup wizard, you have to follow this tutorial : https://docs.bunkerweb.io/latest/web-ui/#setup-wizard

alwinhb commented 2 weeks ago

@TheophileDiot Thanks for the link, I tried using the docker compose yaml present at this link but Still I get - "Nothing to see here"

Can you guide me with the right docker compose.yaml that I can use for my local setup?