TechnitiumSoftware / DnsServer

Technitium DNS Server
https://technitium.com/dns/
GNU General Public License v3.0
4.27k stars 418 forks source link

Exposing HTTPS port isn't respected by just the expected environment variables #709

Closed ceramey1997 closed 11 months ago

ceramey1997 commented 1 year ago

I am running this dns service locally and would like to route its traffic using Traefik. I have a wildcart cert that i use for all my local services and house their dns records in technitium. But, I would also like to use the address dns.whatever.whatever instead of my.ip:5380

I was under the impression based on the sample docker files and docker compose files that if I set DNS_SERVER_WEB_SERVICE_HTTPS_PORT and DNS_SERVER_WEB_SERVICE_ENABLE_HTTPS then I would be able to use the default https port of 53443 which i could then route through traefik. however it seems that there is code that blocks that logic here.

It looks like to me - in order to have the app listening on the https ports specified via the environment variables you also have to certs in the _webServerTlsCertificateCollection.

If my statement is true, I think that either

  1. Documentation should be updated to reflect this
  2. Technitium should not require certs in its own configuration to expose an https port.
ShreyasZare commented 1 year ago

Thanks for the post. The environment variables that are used with docker compose file works only for the first time the container runs. Subsequently, the DNS server's config file will be used to load the settings.

however it seems that there is code that blocks that logic here.

You are referring to Block Page app in there which is totally not related to the DNS server's web service.

Currently, there is no environment variable available to set the certificate path. There is only DNS_SERVER_WEB_SERVICE_USE_SELF_SIGNED_CERT which will generate a self signed cert for the web service.

If you wish to configure the TLS cert then you can use the HTTP API using curl and jq commands. For example, you can use the following bash script to setup HTTPS with your cert:

DNS_TOKEN=`curl "http://localhost:5380/api/user/login?user=admin&pass=admin" | jq -r ".token"`
curl "http://localhost:5380/api/settings/set?token=$DNS_TOKEN&webServiceEnableTls=true&webServiceTlsPort=53443&webServiceTlsCertificatePath=\path\to\cert.pfx"

This way you can configure anything that you wish to have when the DNS server is deployed.