pschiffe / docker-pdns

Docker images for PowerDNS
MIT License
270 stars 80 forks source link

`pdns-recursor` overrides address and port settings #110

Closed troykelly closed 1 year ago

troykelly commented 1 year ago

The configuration below get's overridden with the default 0.0.0.0 53 settings. Noting that the local-address=0.0.0.0 and local-port=53 settings are added to the config file even when those values are supplied by environment variables.

  # Recursive Nameserver
  pdns_recursor:
    <<: *default-opts
    image: pschiffe/pdns-recursor:latest
    container_name: pdns_recursor
    network_mode: host
    restart: unless-stopped
    environment:
      - PDNS_api_key=${PDNS_RECURSOR_API_KEY}
      - PDNS_webserver=yes
      - PDNS_webserver_address=127.0.0.1
      - PDNS_webserver_password=${PDNS_RECURSOR_WEBSERVER_PASSWORD}
      - "PDNS_webserver-allow-from=::"
      - "PDNS_local-address=127.0.0.1:953"
      - "PDNS_local-port=953"
[root@test-dns-001 /]# cat /etc/pdns-recursor/recursor.conf 
allow-from=0.0.0.0/0
api-key=password
daemon=no
local-address=127.0.0.1:953
local-port=953
local-address=0.0.0.0
local-port=53
setgid=pdns-recursor
setuid=pdns-recursor
webserver=yes
webserver-allow-from=::
webserver-address=127.0.0.1
webserver-password=password
troykelly commented 1 year ago

This issue was caused by the environment variables using hyphens, so doubling up when the jinja template is created.

I guess this is more a feature than a bug.

pschiffe commented 1 year ago

Hi @troykelly, the underscores are translated to hyphens in the template to avoid this kind of issues - https://github.com/pschiffe/docker-pdns/blob/master/pdns-recursor/recursor.conf.tpl So you should be able to do:

    environment:
      - PDNS_api_key=${PDNS_RECURSOR_API_KEY}
      - PDNS_webserver=yes
      - PDNS_webserver_address=127.0.0.1
      - PDNS_webserver_password=${PDNS_RECURSOR_WEBSERVER_PASSWORD}
      - PDNS_webserver_allow_from="::"
      - PDNS_local_address="127.0.0.1:953"
      - PDNS_local_port=953
pschiffe commented 1 year ago

And when you define it like this, the defaults from the Dockerfile will be overwritten properly. Now I see what the problem was exactly..