-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-compose.yaml
227 lines (215 loc) · 7.49 KB
/
docker-compose.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
---
version: "3.5"
networks:
dns_network:
name: dns_network
driver: bridge
driver_opts:
encrypted: "true"
ipam:
config:
- subnet: 172.16.1.0/24
attachable: false
services:
# DoH server container
doh_server:
container_name: doh_server
hostname: ${HOSTNAME:-dns_server}
image: cielquan/doh_server:latest
environment:
- TZ=${TIMEZONE:-Europe/Berlin}
volumes:
- type: bind
source: /etc/localtime
target: /etc/localtime
read_only: true
- type: bind
source: ./doh-docker/data/doh-server.conf
target: /opt/dns-over-https/doh-server.conf
expose:
- "8053"
networks:
dns_network:
ipv4_address: 172.16.1.2
restart: always
labels:
- traefik.enable=true
# DoH request handling
- traefik.http.routers.DohServer.rule=Host(`doh.${DOMAIN}`) && Path(`/dns-query`)
- traefik.http.routers.DohServer.middlewares=SecureHeaders
- traefik.http.routers.DohServer.service=DohServer
- traefik.http.services.DohServer.loadbalancer.server.port=8053
# pihole container
pihole:
container_name: pihole
hostname: ${HOSTNAME:-dns_server}
depends_on:
- unbound
image: pihole/pihole:latest
environment:
- TZ=${TIMEZONE:-Europe/Berlin}
- FTLCONF_REPLY_ADDR4=${HOST_IP}
- PIHOLE_DNS_=172.16.1.4#53
- WEBTHEME=default-darker
- WEBPASSWORD=${PIHOLE_WEBPASSWORD}
- DOMAIN=${DOMAIN}
- HOST_IP=${HOST_IP}
volumes:
- type: bind
source: /etc/localtime
target: /etc/localtime
read_only: true
- type: bind
source: ./pihole-docker/data/resolv.conf
target: /etc/resolv.conf
read_only: true
- type: bind
source: ./pihole-docker/data/pihole/
target: /etc/pihole/
- type: bind
source: ./pihole-docker/data/dnsmasq.d/
target: /etc/dnsmasq.d/
# s6 scripts
- type: bind
source: ./pihole-docker/scripts/s6_cont-init.d/01-conf-dnsmasq.sh
target: /etc/cont-init.d/01-conf-dnsmasq.sh
ports:
- "53:53/tcp"
- "53:53/udp"
expose:
- "80"
networks:
dns_network:
ipv4_address: 172.16.1.3
dns:
- 127.0.0.1
restart: always
labels:
- traefik.enable=true
# Middleware to make sure /admin is at the start of the path for pihole dashboard
- traefik.http.middlewares.AddAdminPath.replacepathregex.regex=^/((?i:(admin)/{0,1}|.{0})(.*))
- traefik.http.middlewares.AddAdminPath.replacepathregex.replacement=/admin/$$3
# pihole dashboard
- traefik.http.routers.PiholeGui.rule=Host(`pihole.${DOMAIN}`)
- traefik.http.routers.PiholeGui.middlewares=AddAdminPath,SecureHeaders
- traefik.http.routers.PiholeGui.service=PiholeGui
- traefik.http.services.PiholeGui.loadbalancer.server.port=80
# DoT forward
- traefik.tcp.routers.PiholeDot.rule=HostSNI(`dot.${DOMAIN}`)
- traefik.tcp.routers.PiholeDot.entrypoints=dot
- traefik.tcp.routers.PiholeDot.tls=true
- traefik.tcp.routers.PiholeDot.tls.certresolver=leresolver
- traefik.tcp.routers.PiholeDot.service=PiholeDns
- traefik.tcp.services.PiholeDns.loadbalancer.server.port=53
# unbound container
unbound:
container_name: unbound
hostname: ${HOSTNAME:-dns_server}
image: mvance/unbound:latest
environment:
- TZ=${TIMEZONE:-Europe/Berlin}
volumes:
- type: bind
source: /etc/localtime
target: /etc/localtime
read_only: true
- type: bind
source: ./unbound-docker/data
target: /opt/unbound/etc/unbound/
- type: bind
source: ./unbound-docker/scripts/unbound.sh
target: /unbound.sh
read_only: true
expose:
- "53"
networks:
dns_network:
ipv4_address: 172.16.1.4
restart: always
labels:
- traefik.enable=false
# træfik container
traefik:
container_name: traefik
hostname: ${HOSTNAME:-dns_server}
image: traefik:v3.0
environment:
- TZ=${TIMEZONE:-Europe/Berlin}
- NAMECOM_API_TOKEN=${NAMECOM_API_TOKEN}
- NAMECOM_USERNAME=${NAMECOM_USERNAME}
volumes:
- type: bind
source: /etc/localtime
target: /etc/localtime
read_only: true
- type: bind
source: /var/run/docker.sock
target: /var/run/docker.sock
read_only: true
- type: bind
source: ./traefik-docker/data/
target: /etc/traefik/
read_only: true
ports:
- "80:80"
- "443:443"
- "853:853"
networks:
dns_network:
ipv4_address: 172.16.1.5
restart: always
command:
- "--global.checknewversion=true"
- "--global.sendanonymoususage=false"
- "--log=true"
- "--log.format=common"
- "--log.level=INFO" # DEBUG, INFO, WARN, ERROR, FATAL, PANIC
- "--accesslog=true"
- "--accesslog.format=common"
- "--api=true"
- "--api.dashboard=true"
- "--api.debug=false"
- "--api.insecure=false"
- "--providers.docker=true"
- "--providers.docker.network=dns_network"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web=true"
- "--entrypoints.web.address=:80"
- "--entrypoints.web.http.redirections.entryPoint.to=websecure"
- "--entrypoints.web.http.redirections.entryPoint.scheme=https"
- "--entrypoints.websecure=true"
- "--entryPoints.websecure.address=:443"
- "--entrypoints.websecure.asdefault=true"
- "--entrypoints.websecure.http.tls=true"
- "--entrypoints.websecure.http.tls.certResolver=leresolver"
- "--entrypoints.dot=true"
- "--entrypoints.dot.address=:853"
##############################
# SSL CERTIFICATE CONFIG Start
##############################
- "--certificatesresolvers.leresolver.acme.email=${ACME_EMAIL}"
- "--certificatesresolvers.leresolver.acme.caserver=${ACME_CASERVER:-https://acme-v02.api.letsencrypt.org/directory}"
- "--certificatesresolvers.leresolver.acme.dnschallenge=true"
# Providers list: https://docs.traefik.io/https/acme/#providers
- "--certificatesresolvers.leresolver.acme.dnschallenge.provider=${ACME_DNSCHALLENGE_PROVIDER:-namedotcom}"
##############################
# SSL CERTIFICATE CONFIG End
##############################
labels:
- traefik.enable=true
# Middleware to add security related headers
- traefik.http.middlewares.SecHeadersSniff.headers.contenttypenosniff=true # buggy on traefik
- traefik.http.middlewares.SecHeaders.headers.browserxssfilter=true
- traefik.http.middlewares.SecHeaders.headers.framedeny=true
- traefik.http.middlewares.SecHeaders.headers.forcestsheader=true
- traefik.http.middlewares.SecHeaders.headers.stsincludesubdomains=true
- traefik.http.middlewares.SecHeaders.headers.stspreload=true
- traefik.http.middlewares.SecHeaders.headers.stsseconds=63072000
- traefik.http.middlewares.SecureHeaders.chain.middlewares=SecHeaders,SecHeadersSniff
- traefik.http.middlewares.SecureHeadersTraefik.chain.middlewares=SecHeaders
# Middleware to add basic auth for traefik dashboard
- traefik.http.middlewares.TraefikAuth.basicauth.usersfile=/etc/traefik/.htpasswd
# traefik dashboard
- traefik.http.routers.Traefik.rule=Host(`traefik.${DOMAIN}`)
- traefik.http.routers.Traefik.middlewares=TraefikAuth,SecureHeadersTraefik
- traefik.http.routers.Traefik.service=api@internal