Skip to content

Commit

Permalink
Conf cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dubo-dubon-duponey committed Feb 23, 2024
1 parent 341adda commit 6b159b1
Show file tree
Hide file tree
Showing 20 changed files with 148 additions and 184 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ ENV DNS_FORWARD_UPSTREAM_IP_1="tls://1.1.1.1"
ENV DNS_FORWARD_UPSTREAM_IP_2="tls://1.0.0.1"

ENV DNS_PORT=53
ENV DNS_OVER_GRPC_PORT=553
# ENV DNS_OVER_GRPC_PORT=553
ENV DNS_STUFF_MDNS=false

ENV METRICS_PORT=9253
Expand All @@ -209,7 +209,7 @@ ENV METRICS_PORT=9253
EXPOSE $DNS_PORT/udp
EXPOSE $DNS_OVER_TLS_PORT/tcp
EXPOSE $DNS_OVER_TLS_LEGO_PORT/tcp
EXPOSE $DNS_OVER_GRPC_PORT/tcp
#EXPOSE $DNS_OVER_GRPC_PORT/tcp
EXPOSE $METRICS_PORT/tcp

# Lego just needs /certs to work
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ For forwarding:
You can also tweak the following:

* DNS_PORT (default to 53)
<!--
* DNS_OVER_GRPC_PORT (default to 553)
-->
* DNS_STUFF_MDNS: convenient little trick to respond for certain mDNS queries over traditional DNS
* METRICS_PORT for Prometheuse (default to 9253)

Expand Down
17 changes: 12 additions & 5 deletions context/runtime/boot/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ source "$root/helpers.sh"

helpers::dir::writable /certs

LOG_LEVEL=${LOG_LEVEL:-}

# DNS over tls settings
DNS_OVER_TLS_ENABLED="${DNS_OVER_TLS_ENABLED:-}"
DNS_OVER_TLS_DOMAIN="${DNS_OVER_TLS_DOMAIN:-}"
Expand All @@ -24,7 +26,7 @@ DNS_FORWARD_UPSTREAM_IP_2="${DNS_FORWARD_UPSTREAM_IP_2:-}"

# Other DNS settings
DNS_PORT="${DNS_PORT:-}"
DNS_OVER_GRPC_PORT="${DNS_OVER_GRPC_PORT:-}"
# DNS_OVER_GRPC_PORT="${DNS_OVER_GRPC_PORT:-}"
DNS_STUFF_MDNS="${DNS_STUFF_MDNS:-}"

# Metrics settings
Expand Down Expand Up @@ -66,10 +68,10 @@ loop(){
done
}

no_tls=-no
with_tls=
# If we have a domain, get certificates for that, and the appropriate config
if [ "$DNS_OVER_TLS_ENABLED" == true ]; then
no_tls=
with_tls="+tls"

# Initial registration, blocking
certs::renew "$DNS_OVER_TLS_DOMAIN" "$DNS_OVER_TLS_LEGO_EMAIL" "$DNS_OVER_TLS_PORT" "$DNS_OVER_TLS_LE_USE_STAGING"
Expand All @@ -80,7 +82,12 @@ fi

# Choose config based on environment values
[ "$DNS_FORWARD_ENABLED" == true ] && mode=forward || mode=recursive
[ "$DNS_STUFF_MDNS" == true ] && mod=-mdns || mod=
[ "$DNS_STUFF_MDNS" == true ] && with_mdns=+mdns || with_mdns=

args=(-conf "/config/coredns-${mode}${with_tls}${with_mdns}.conf")

normalized_log_level="$(printf "%s" "$LOG_LEVEL" | tr '[:upper:]' '[:lower:]')"
[ "$normalized_log_level" != "error" ] && [ "$normalized_log_level" != "warning" ] || args+=(-quiet)

# Get coredns started
exec coredns -conf /config/coredns${no_tls}-tls-${mode}${mod}.conf "$@"
exec coredns "${args[@]}" "$@"
18 changes: 18 additions & 0 deletions context/runtime/config/coredns-forward+mdns.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import snips/mdns.conf

# Classic DNS on 53, forwarding to an upstream
.:{$DNS_PORT} {
import snips/hosts.conf
import snips/forward.conf
import snips/cache.conf
import snips/monitor.conf
}

{$HEALTHCHECK_QUESTION}:{$DNS_PORT} {
import snips/forward.conf
}

whoami:{$DNS_PORT} {
# https://coredns.io/plugins/whoami/
whoami
}
24 changes: 24 additions & 0 deletions context/runtime/config/coredns-forward+tls.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
tls://.:{$DNS_OVER_TLS_PORT} {
tls /certs/certificates/{$DOMAIN}.crt /certs/certificates/{$DOMAIN}.key /certs/certificates/{$DOMAIN}.issuer.crt

import snips/hosts.conf
import snips/forward.conf
import snips/cache.conf
import snips/monitor.conf
}

.:{$DNS_PORT} {
import snips/hosts.conf
import snips/forward.conf
import snips/cache.conf
import snips/monitor.conf
}

{$HEALTHCHECK_QUESTION}:{$DNS_PORT} {
import snips/forward.conf
}

whoami:{$DNS_PORT} {
# https://coredns.io/plugins/whoami/
whoami
}
16 changes: 16 additions & 0 deletions context/runtime/config/coredns-forward.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Classic DNS on 53, forwarding to an upstream
.:{$DNS_PORT} {
import snips/hosts.conf
import snips/forward.conf
import snips/cache.conf
import snips/monitor.conf
}

{$HEALTHCHECK_QUESTION}:{$DNS_PORT} {
import snips/forward.conf
}

whoami:{$DNS_PORT} {
# https://coredns.io/plugins/whoami/
whoami
}
30 changes: 0 additions & 30 deletions context/runtime/config/coredns-no-tls-forward-mdns.conf

This file was deleted.

25 changes: 0 additions & 25 deletions context/runtime/config/coredns-no-tls-forward.conf

This file was deleted.

22 changes: 0 additions & 22 deletions context/runtime/config/coredns-no-tls-recursive.conf

This file was deleted.

24 changes: 24 additions & 0 deletions context/runtime/config/coredns-recursive+tls.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
tls://.:{$DNS_OVER_TLS_PORT} {
tls /certs/certificates/{$DNS_OVER_TLS_DOMAIN}.crt /certs/certificates/{$DNS_OVER_TLS_DOMAIN}.key /certs/certificates/{$DNS_OVER_TLS_DOMAIN}.issuer.crt

import snips/hosts.conf
import snips/recursive.conf
import snips/cache.conf
import snips/monitor.conf
}

.:{$DNS_PORT} {
import snips/hosts.conf
import snips/recursive.conf
import snips/cache.conf
import snips/monitor.conf
}

{$HEALTHCHECK_QUESTION}:{$DNS_PORT} {
import snips/forward.conf
}

whoami:{$DNS_PORT} {
# https://coredns.io/plugins/whoami/
whoami
}
15 changes: 15 additions & 0 deletions context/runtime/config/coredns-recursive.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.:{$DNS_PORT} {
import snips/hosts.conf
import snips/recursive.conf
import snips/cache.conf
import snips/monitor.conf
}

{$HEALTHCHECK_QUESTION}:{$DNS_PORT} {
import snips/forward.conf
}

whoami:{$DNS_PORT} {
# https://coredns.io/plugins/whoami/
whoami
}
48 changes: 0 additions & 48 deletions context/runtime/config/coredns-tls-forward.conf

This file was deleted.

42 changes: 0 additions & 42 deletions context/runtime/config/coredns-tls-recursive.conf

This file was deleted.

2 changes: 2 additions & 0 deletions context/runtime/config/snips/cache.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://coredns.io/plugins/cache/
cache 3600
5 changes: 5 additions & 0 deletions context/runtime/config/snips/forward.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# https://coredns.io/plugins/forward/
forward . {$DNS_FORWARD_UPSTREAM_IP_1} {$DNS_FORWARD_UPSTREAM_IP_2} {
tls_servername {$DNS_FORWARD_UPSTREAM_NAME}
health_check 5s
}
4 changes: 4 additions & 0 deletions context/runtime/config/snips/hosts.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# https://coredns.io/plugins/hosts/
hosts {
fallthrough
}
4 changes: 4 additions & 0 deletions context/runtime/config/snips/mdns.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
local {
# https://coredns.io/explugins/mdns/
mdns local 1
}
13 changes: 13 additions & 0 deletions context/runtime/config/snips/monitor.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# https://coredns.io/plugins/health/
health localhost:8091
# https://coredns.io/plugins/pprof/
pprof localhost:6053
# https://coredns.io/plugins/metrics/
prometheus :{$METRICS_PORT}
# https://coredns.io/plugins/log/
log
# {combined}
# https://coredns.io/plugins/errors/
errors
# https://coredns.io/plugins/reload/
reload
2 changes: 2 additions & 0 deletions context/runtime/config/snips/recursive.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://coredns.io/explugins/unbound/
unbound
Loading

0 comments on commit 6b159b1

Please sign in to comment.