Deploy coredns as a proxy to Docker's internal DNS

This commit is contained in:
Jake Howard 2023-12-14 21:04:26 +00:00
parent 7381c1f10a
commit 7ad5d6e51e
Signed by: jake
GPG key ID: 57AFB45680EDD477
5 changed files with 59 additions and 0 deletions

View file

@ -105,6 +105,7 @@
- commento - commento
- website - website
- remark42 - remark42
- coredns
- hosts: jellyfin - hosts: jellyfin
roles: roles:

View file

@ -0,0 +1,21 @@
. {
errors
cancel
# Only allow requests to `.docker` records
view docker {
expr name() matches '^[a-zA-Z0-9-_]+\\.docker\\.$'
}
# Strip the `.docker` suffix
rewrite name suffix .docker . answer auto
# Forward requests to Docker's DNS server
forward . 127.0.0.11
}
. {
acl {
block
}
}

View file

@ -0,0 +1,16 @@
version: "2.3"
services:
coredns:
image: coredns/coredns:latest
volumes:
- ./Corefile:/home/nonroot/Corefile:ro
ports:
- "{{ private_ip }}:5353:53/udp"
networks:
- default
- traefik
networks:
traefik:
external: true

View file

@ -0,0 +1,4 @@
- name: restart coredns
shell:
chdir: /opt/coredns
cmd: "{{ docker_update_command }}"

View file

@ -0,0 +1,17 @@
- name: Create install directory
file:
path: /opt/coredns
state: directory
owner: "{{ docker_user.name }}"
mode: "{{ docker_compose_directory_mask }}"
become: true
- name: Install compose file
template:
src: files/docker-compose.yml
dest: /opt/coredns/docker-compose.yml
mode: "{{ docker_compose_file_mask }}"
owner: "{{ docker_user.name }}"
validate: docker-compose -f %s config
notify: restart coredns
become: true