Skip to content

Commit 7aaf2f0

Browse files
committed
Refs #248 Split DNS into internal DNS (intdns) and Auto DNS (autodns) to distinguish between PHP DNS queries and Host OS DNS queries
1 parent cf328ef commit 7aaf2f0

File tree

3 files changed

+99
-18
lines changed

3 files changed

+99
-18
lines changed

docker-compose.override.yml-example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@ services:
1818
ipv4_address: 172.16.238.200
1919
# (Optional) For ease of use always automatically start these:
2020
depends_on:
21-
- bind
2221
- php
2322
- httpd

docker-compose.yml

Lines changed: 85 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,84 @@
2525
version: '2.1'
2626

2727

28-
################################################################################
28+
###################################################################################################
2929
# SERVICES
30-
################################################################################
30+
###################################################################################################
3131
services:
3232

3333
# ------------------------------------------------------------
34-
# Bind (DNS Server)
34+
# Internal DNS for PHP container (Required)
3535
# ------------------------------------------------------------
36-
bind:
36+
# This container must always run and is only intended for the
37+
# PHP-FPM container so that they are able to resolve custom
38+
# DNS and direct all requests to the Devilbox http server.
39+
intdns:
3740
image: cytopia/bind:0.15
3841
restart: always
42+
environment:
43+
##
44+
## Debug?
45+
##
46+
- DEBUG_ENTRYPOINT=${DEBUG_COMPOSE_ENTRYPOINT}
47+
48+
##
49+
## ---- THIS LINE MAKES THE MAGIC HAPPEN ----
50+
##
51+
## Ensure all wildcard DNS requests from the PHP-Container
52+
## resolve to the Devilbox http server
53+
##
54+
- WILDCARD_DNS=${TLD_SUFFIX:-loc}=172.16.238.11
55+
56+
##
57+
## Add extra hosts to be resolvable
58+
##
59+
- EXTRA_HOSTS=${EXTRA_HOSTS}
60+
61+
##
62+
## Forwarding
63+
##
64+
- DNS_FORWARDER=${BIND_DNS_RESOLVER:-8.8.8.8,8.8.4.4}
65+
66+
##
67+
## Security
68+
##
69+
- DNSSEC_VALIDATE=${BIND_DNSSEC_VALIDATE:-no}
70+
71+
##
72+
## Time settings
73+
##
74+
- TTL_TIME=${BIND_TTL_TIME}
75+
- REFRESH_TIME=${BIND_REFRESH_TIME}
76+
- RETRY_TIME=${BIND_RETRY_TIME}
77+
- EXPIRY_TIME=${BIND_EXPIRY_TIME}
78+
- MAX_CACHE_TIME=${BIND_MAX_CACHE_TIME}
79+
80+
##
81+
## Query log
82+
##
83+
- DOCKER_LOGS=${BIND_LOG_DNS_QUERIES}
84+
85+
dns:
86+
- 127.0.0.1
87+
88+
# MacOS and Windows have this by default, this hack also allows it for Linux
89+
extra_hosts:
90+
docker.for.lin.host.internal: 172.16.238.1
91+
docker.for.lin.localhost: 172.16.238.1
92+
93+
hostname: intdns
94+
networks:
95+
app_net:
96+
ipv4_address: 172.16.238.100
97+
98+
99+
# ------------------------------------------------------------
100+
# AutoDNS: DNS for your host operating system (Optional)
101+
# ------------------------------------------------------------
102+
# This container is intended to provide Auto-DNS for your
103+
# host operating system, if you wish so.
104+
autodns:
105+
image: cytopia/bind:0.15
39106
ports:
40107
# [local-machine:]local-port:docker-port
41108
- "${LOCAL_LISTEN_ADDR}${HOST_PORT_BIND:-1053}:53/tcp"
@@ -48,9 +115,17 @@ services:
48115
- DEBUG_ENTRYPOINT=${DEBUG_COMPOSE_ENTRYPOINT}
49116

50117
##
118+
## ---- THIS LINE MAKES THE MAGIC HAPPEN ----
119+
##
120+
## This line assigns the IP address on which the Devilbox is available
121+
## to your host operating system.
51122
## Bind wildcard/host settings
52123
##
53-
- WILDCARD_DNS=${TLD_SUFFIX:-loc}=127.0.0.1
124+
- WILDCARD_DNS=${TLD_SUFFIX:-loc}=${AUTODNS_HOST_ADDRESS}
125+
126+
##
127+
## Add extra hosts to be resolvable
128+
##
54129
- EXTRA_HOSTS=${EXTRA_HOSTS}
55130

56131
##
@@ -85,10 +160,10 @@ services:
85160
docker.for.lin.host.internal: 172.16.238.1
86161
docker.for.lin.localhost: 172.16.238.1
87162

88-
hostname: bind
163+
hostname: autodns
89164
networks:
90165
app_net:
91-
ipv4_address: 172.16.238.100
166+
ipv4_address: 172.16.238.101
92167

93168

94169
# ------------------------------------------------------------
@@ -199,7 +274,7 @@ services:
199274
- ${DEVILBOX_PATH}/ca:/ca:rw${MOUNT_OPTIONS}
200275

201276
depends_on:
202-
- bind
277+
- intdns
203278

204279

205280
# ------------------------------------------------------------
@@ -291,7 +366,6 @@ services:
291366
- ${DEVILBOX_PATH}/ca:/ca:rw${MOUNT_OPTIONS}
292367

293368
depends_on:
294-
- bind
295369
- php
296370

297371

@@ -355,7 +429,6 @@ services:
355429
- ${HOST_PATH_MYSQL_DATADIR}/${MYSQL_SERVER}:/var/lib/mysql:rw${MOUNT_OPTIONS}
356430

357431
depends_on:
358-
- bind
359432
- php
360433
- httpd
361434

@@ -392,7 +465,6 @@ services:
392465
- ${HOST_PATH_PGSQL_DATADIR}/${PGSQL_SERVER}:/var/lib/postgresql/data/pgdata:rw${MOUNT_OPTIONS}
393466

394467
depends_on:
395-
- bind
396468
- php
397469
- httpd
398470

@@ -425,7 +497,6 @@ services:
425497
- ${DEVILBOX_PATH}/log/redis-${REDIS_SERVER}:/var/log/redis:rw${MOUNT_OPTIONS}
426498

427499
depends_on:
428-
- bind
429500
- php
430501
- httpd
431502

@@ -453,7 +524,6 @@ services:
453524
- ${DEVILBOX_PATH}/log/memcd-${MEMCD_SERVER}:/var/log/memcd:rw${MOUNT_OPTIONS}
454525

455526
depends_on:
456-
- bind
457527
- php
458528
- httpd
459529

@@ -481,14 +551,13 @@ services:
481551
- ${HOST_PATH_MONGO_DATADIR}/${MONGO_SERVER}:/data/db:rw${MOUNT_OPTIONS}
482552

483553
depends_on:
484-
- bind
485554
- php
486555
- httpd
487556

488557

489-
################################################################################
558+
###################################################################################################
490559
# NETWORK
491-
################################################################################
560+
###################################################################################################
492561
networks:
493562
app_net:
494563
driver: bridge

env-example

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ HOST_PORT_MONGO=27017
628628

629629
################################################################################
630630
###
631-
### 10. Bind Docker Settings
631+
### 10. AutoDNS Settings
632632
###
633633
################################################################################
634634

@@ -637,6 +637,19 @@ HOST_PORT_MONGO=27017
637637
###
638638
HOST_PORT_BIND=1053
639639

640+
###
641+
### The IP address to which direct all DNS resolutions.
642+
###
643+
### This settings really depend on where you want to access your Devilbox projects
644+
### from your host computer's browser.
645+
###
646+
### If you access the Devilbox on 127.0.0.1, then set this to 127.0.0.1
647+
### If however you're running Docker Toolbox and the Devilbox IP address is something
648+
### like 192.168.99.100, then set it to 192.168.99.100. (Note, this is only an example)
649+
### In case of Docker Toolbox, you will have to find out the IP address first.
650+
###
651+
AUTODNS_HOST_ADDRESS=127.0.0.1
652+
640653
###
641654
### Add comma separated DNS server from which you want to receive DNS
642655
### You can also add DNS servers from your LAN (if any are available)

0 commit comments

Comments
 (0)