sameersbn / docker-bind

Dockerize BIND DNS server with webmin for DNS administration
MIT License
913 stars 333 forks source link

Can not change SSL mode for webmin #98

Closed jonasstrehle closed 4 years ago

jonasstrehle commented 4 years ago

I'm not getting webmin for docker-bind working. So I'm using traefik as proxy and listening on the dns.mydomain.com subdomain (SSL).

Navigating to the URI all I'm getting is a 502 Bad Gateway error message. Navigating inside the docker to the internal IP (curl -G myinternalip:10000) returns the error This web server is running in SSL mode. Try the URL <a href='https://dns-main:10000/'>https://docker-bind:10000/</a> instead..

Note that in the running container the file /etc/webmin/miniserv.conf does not seems to be changed (SSL=1) instead of SSL=0. Adding a volume mount to override the file (./miniserv.conf:/etc/webmin/miniserv.conf) is not possible due to this error: rm: cannot remove '/etc/webmin/miniserv.conf': Device or resource busy

I'm not really sure how to go on ... so does anybody know how to fix this? Any help would be really appreciated.

docker-compose.yml service:

dns-bind:
    container_name: docker-bind
    restart: always
    image: sameersbn/bind:9.16.1-20200524
    hostname: docker-bind
    environment:
      - WEBMIN_INIT_SSL_ENABLED=false
      - WEBMIN_INIT_REFERERS=dns.mydomain.com
      - WEBMIN_ENABLED=true
    ports:
      - 53:53/udp
      - 53:53/tcp
      - 10000:10000/tcp
    expose:
      - 10000
    volumes:
      - /srv/docker/bind:/data
      # - ./miniserv.conf:/etc/webmin/miniserv.conf
    networks:
      - main
    labels:
      - traefik.enable=true
      - traefik.port=10000
      - traefik.http.routers.dns.rule=Host(`dns.mydomain.com`)
      - traefik.http.routers.dns.entrypoints=web
      - traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https
      - traefik.http.routers.dns.middlewares=redirect-to-https@docker
      - traefik.http.routers.dns-secured.rule=Host(`dns.mydomain.com`)
      - traefik.http.routers.dns-secured.tls=true
      - traefik.http.routers.dns-secured.tls.certresolver=myhttpchallenge
jonasstrehle commented 4 years ago

Closing this issue. It seems that defining the environment variables inside the docker-compose is not working with the recent version. However I'm using a a custom-built image as workaround.

zufardhiyaulhaq commented 4 years ago

can you explain whats wrong here @jonasstrehle? I am also using docker compose. Is there any problem with docker compose? the environment variable loaded correctly in the container.

zufardhiyaulhaq commented 4 years ago

because ROOT_PASSWORD env variable is working fine in my case. But webmin variables is not working, even though it's loaded in the env.

jhaoheng commented 4 years ago

Got the sam problem

adavoudi commented 4 years ago

In my case it was because of the following piece of code:

https://github.com/sameersbn/docker-bind/blob/508bc5a17c12a6d17b0c91aa0fe11f5253cbd081/entrypoint.sh#L98-L109

As you see, the first_init() function only runs if the /data/.initialized file does not exist (i.e. it is the first initialization). As I was mounting the /data directory on the host, the file was created the first time I ran the docker-compose file. After removing the .initialized file manually, the environment variables worked as expected.

adavoudi commented 4 years ago
environment:
  - WEBMIN_INIT_SSL_ENABLED=false
  - WEBMIN_INIT_REFERERS=dns.mydomain.com
  - WEBMIN_ENABLED=true

You also need to add the following variable WEBMIN_INIT_REDIRECT_PORT=80 in order to redirect to http://dns.mydomain.com:80 after logging in.