bunkerity / bunkerweb

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

[BUG] Can not resolve domain name set by extra_hosts: #1446

Open OrvilleQ opened 2 months ago

OrvilleQ commented 2 months ago

What happened?

I install Bunkerweb with Docker compose, with extra_hosts: - host.docker.internal:host-gateway which mapped IP address of the host 172.17.0.1 to host.docker.internal inside container's /etc/hosts.

Since I wanna proxy a server from the host, I add a service with Reverse proxy host http://host.docker.internal:19999

image

But I got 502 Bad Gateway when access the website, and the log says 2024/09/03 15:41:30 [error] 2857#2857: *2169 host.docker.internal could not be resolved (3: Host not found),

How to reproduce?

  1. install Bunkerweb using Docker compose, with extra_hosts: - host.docker.internal:host-gateway
  2. create a service which reverse proxying http://host.docker.internal:port
  3. access the domain

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=FSN00
      - DATABASE_URI=postgresql://bunkerweb:xxxxxxxxxxxxxxx@host.docker.internal:5432/bunkerweb
      - AUTOCONF_MODE=yes
      - MULTISITE=yes
      - API_WHITELIST_IP=127.0.0.0/8 10.25.0.0/24
    volumes:
      - /var/lib/bunkerweb/certs:/var/lib/certs
    networks:
      - bw-universe
      - bw-services
    extra_hosts:
      - host.docker.internal:host-gateway

  bw-autoconf:
    image: bunkerity/bunkerweb-autoconf:1.5.9
    depends_on:
      - bunkerweb
      - bw-docker
    environment:
      - DATABASE_URI=postgresql://bunkerweb:xxxxxxxxxxxxxxx@host.docker.internal:5432/bunkerweb
      - AUTOCONF_MODE=yes
      - DOCKER_HOST=tcp://bw-docker:2375
    networks:
      - bw-universe
      - bw-docker
    extra_hosts:
      - host.docker.internal:host-gateway

  bw-scheduler:
    image: bunkerity/bunkerweb-scheduler:1.5.9
    depends_on:
      - bunkerweb
      - bw-docker
    environment:
      - DATABASE_URI=postgresql://bunkerweb:xxxxxxxxxxxxxxx@host.docker.internal:5432/bunkerweb
      - DOCKER_HOST=tcp://bw-docker:2375
      - AUTOCONF_MODE=yes
    networks:
      - bw-universe
      - bw-docker
    extra_hosts:
      - host.docker.internal:host-gateway

  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.9
    networks:
      bw-docker:
      bw-universe:
        aliases:
          - bw-ui
    environment:
      - DATABASE_URI=postgresql://bunkerweb:xxxxxxxxxxxxxxx@host.docker.internal:5432/bunkerweb
      - DOCKER_HOST=tcp://bw-docker:2375
      - AUTOCONF_MODE=yes
    labels:
      - "bunkerweb.SERVER_NAME=xxxxxxxxxxxxxxx"
      - "bunkerweb.USE_UI=yes"
      - "bunkerweb.USE_REVERSE_PROXY=yes"
      - "bunkerweb.REVERSE_PROXY_URL=/xxxxxxxxxxxxxxx"
      - "bunkerweb.REVERSE_PROXY_HOST=http://bw-ui:7000"
      - "bunkerweb.INTERCEPTED_ERROR_CODES=400 404 405 413 429 500 501 502 503 504"
      - "bunkerweb.MAX_CLIENT_SIZE=50m"
      - "bunkerweb.AUTO_LETS_ENCRYPT=yes"
    extra_hosts:
      - host.docker.internal:host-gateway

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

Relevant log output

2024/09/03 15:41:30 [error] 2857#2857: *2169 host.docker.internal could not be resolved (3: Host not found), client: 199.xxx.xxx.xxx, server: fsn00.xxx.xxx.xxx, request: "GET / HTTP/2.0", host: "fsn00.xxx.xxx.xxx"

BunkerWeb version

1.5.9

What integration are you using?

Docker

Linux distribution (if applicable)

Rockylinux

Removed private data

Code of Conduct

TheophileDiot commented 1 month ago

Hi, sorry for the (very) late response and thank you for opening this issue. We'll have a look into is asap and let you know