bunkerity / bunkerweb

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

[BUG] UI setup does not work correctly using a Cloudflare tunnel #1673

Open richardfrost2 opened 2 weeks ago

richardfrost2 commented 2 weeks ago

What happened?

When setting up the UI using a Cloudflare tunnel, the setup does not complete. It gives the error "Error The hostname is already in use.", even if the hostname correctly points to the UI container. The expected behavior is that the setup continues.

How to reproduce?

Have a host with cloudflared installed, and set up a tunnel, "bunkerweb.example.com" (names are examples), resolving to localhost:80. Set up bunkerweb in the yaml file you provide docker-compose so that bunkerweb.example.com goes to the UI container "bw-ui". Launch your container group, and connect to bunkerweb.example.com. Fill out the UI for first time signin, setting REVERSE_PROXY_HOST to what is specified in the docker-config.yml file, REVERSE_PROXY_URL to any value, and server name to bunkerweb.example.com.

Configuration file(s) (yaml or .env)

#docker-compose.yml
version: "3.5"

services:
  bunkerweb:
    image: bunkerity/bunkerweb:1.5.10
    ports:
      - 80:8080
      - 443:8443
    labels:
      - "bunkerweb.INSTANCE=yes"
    environment:
      - SERVER_NAME=bunkerweb.example.net
      - MULTISITE=yes
      - API_WHITELIST_IP=127.0.0.0/8 10.20.30.0/24
      - USE_REVERSE_PROXY=yes
      - REVERSE_PROXY_URL=/
    # other services here...
      - bunkerweb.example.net_REVERSE_PROXY_HOST=http://bunkerweb-bw-ui-1:7000
    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:password@bunkerweb-bw-db-1:3306/db # Remember to set a stronger password for the database
      - DOCKER_HOST=tcp://bunkerweb-bw-docker-1: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:password@bunkerweb-bw-db-1:3306/db # Remember to set a stronger password for the database
      - DOCKER_HOST=tcp://bunkerweb-bw-docker-1:2375
    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=password
    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-docker:
    name: bw-docker
  bw-services:
    name: bw-services
    external: true

Relevant log output

10.45.1.45 - - [08/Nov/2024:01:37:32 +0000] "GET / HTTP/1.0" 302 199 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0"
10.45.1.45 - - [08/Nov/2024:01:37:32 +0000] "GET /setup HTTP/1.0" 200 943003 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0"
10.45.1.45 - - [08/Nov/2024:01:38:03 +0000] "GET /setup/check?server_name=bunkerweb.example.net HTTP/1.0" 404 207 "http://bunkerweb.example.net/setup" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0"
[2024-11-08 01:38:12 +0000] [flask_wtf.csrf] [27] [ℹ️ ] - The CSRF session token is missing.
10.45.1.45 - - [08/Nov/2024:01:38:13 +0000] "POST /setup HTTP/1.0" 403 12593 "http://bunkerweb.example.com/setup" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0"

BunkerWeb version

1.5.10

What integration are you using?

Docker

Linux distribution (if applicable)

Ubuntu 24.04.1 LTS x86_64

Removed private data

Code of Conduct

TheophileDiot commented 18 hours ago

Hi @richardfrost2, did you follow this tutorial? https://www.bunkerweb.io/blog/post/bunkerweb-with-cloudflare