Skip to content

Commit

Permalink
Refs #248 Split DNS into internal DNS (intdns) and Auto DNS (autodns)…
Browse files Browse the repository at this point in the history
… to distinguish between PHP DNS queries and Host OS DNS queries
  • Loading branch information
cytopia committed Nov 6, 2018
1 parent cf328ef commit 7aaf2f0
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 18 deletions.
1 change: 0 additions & 1 deletion docker-compose.override.yml-example
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ services:
ipv4_address: 172.16.238.200
# (Optional) For ease of use always automatically start these:
depends_on:
- bind
- php
- httpd
101 changes: 85 additions & 16 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,84 @@
version: '2.1'


################################################################################
###################################################################################################
# SERVICES
################################################################################
###################################################################################################
services:

# ------------------------------------------------------------
# Bind (DNS Server)
# Internal DNS for PHP container (Required)
# ------------------------------------------------------------
bind:
# This container must always run and is only intended for the
# PHP-FPM container so that they are able to resolve custom
# DNS and direct all requests to the Devilbox http server.
intdns:
image: cytopia/bind:0.15
restart: always
environment:
##
## Debug?
##
- DEBUG_ENTRYPOINT=${DEBUG_COMPOSE_ENTRYPOINT}

##
## ---- THIS LINE MAKES THE MAGIC HAPPEN ----
##
## Ensure all wildcard DNS requests from the PHP-Container
## resolve to the Devilbox http server
##
- WILDCARD_DNS=${TLD_SUFFIX:-loc}=172.16.238.11

##
## Add extra hosts to be resolvable
##
- EXTRA_HOSTS=${EXTRA_HOSTS}

##
## Forwarding
##
- DNS_FORWARDER=${BIND_DNS_RESOLVER:-8.8.8.8,8.8.4.4}

##
## Security
##
- DNSSEC_VALIDATE=${BIND_DNSSEC_VALIDATE:-no}

##
## Time settings
##
- TTL_TIME=${BIND_TTL_TIME}
- REFRESH_TIME=${BIND_REFRESH_TIME}
- RETRY_TIME=${BIND_RETRY_TIME}
- EXPIRY_TIME=${BIND_EXPIRY_TIME}
- MAX_CACHE_TIME=${BIND_MAX_CACHE_TIME}

##
## Query log
##
- DOCKER_LOGS=${BIND_LOG_DNS_QUERIES}

dns:
- 127.0.0.1

# MacOS and Windows have this by default, this hack also allows it for Linux
extra_hosts:
docker.for.lin.host.internal: 172.16.238.1
docker.for.lin.localhost: 172.16.238.1

hostname: intdns
networks:
app_net:
ipv4_address: 172.16.238.100


# ------------------------------------------------------------
# AutoDNS: DNS for your host operating system (Optional)
# ------------------------------------------------------------
# This container is intended to provide Auto-DNS for your
# host operating system, if you wish so.
autodns:
image: cytopia/bind:0.15
ports:
# [local-machine:]local-port:docker-port
- "${LOCAL_LISTEN_ADDR}${HOST_PORT_BIND:-1053}:53/tcp"
Expand All @@ -48,9 +115,17 @@ services:
- DEBUG_ENTRYPOINT=${DEBUG_COMPOSE_ENTRYPOINT}

##
## ---- THIS LINE MAKES THE MAGIC HAPPEN ----
##
## This line assigns the IP address on which the Devilbox is available
## to your host operating system.
## Bind wildcard/host settings
##
- WILDCARD_DNS=${TLD_SUFFIX:-loc}=127.0.0.1
- WILDCARD_DNS=${TLD_SUFFIX:-loc}=${AUTODNS_HOST_ADDRESS}

##
## Add extra hosts to be resolvable
##
- EXTRA_HOSTS=${EXTRA_HOSTS}

##
Expand Down Expand Up @@ -85,10 +160,10 @@ services:
docker.for.lin.host.internal: 172.16.238.1
docker.for.lin.localhost: 172.16.238.1

hostname: bind
hostname: autodns
networks:
app_net:
ipv4_address: 172.16.238.100
ipv4_address: 172.16.238.101


# ------------------------------------------------------------
Expand Down Expand Up @@ -199,7 +274,7 @@ services:
- ${DEVILBOX_PATH}/ca:/ca:rw${MOUNT_OPTIONS}

depends_on:
- bind
- intdns


# ------------------------------------------------------------
Expand Down Expand Up @@ -291,7 +366,6 @@ services:
- ${DEVILBOX_PATH}/ca:/ca:rw${MOUNT_OPTIONS}

depends_on:
- bind
- php


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

depends_on:
- bind
- php
- httpd

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

depends_on:
- bind
- php
- httpd

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

depends_on:
- bind
- php
- httpd

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

depends_on:
- bind
- php
- httpd

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

depends_on:
- bind
- php
- httpd


################################################################################
###################################################################################################
# NETWORK
################################################################################
###################################################################################################
networks:
app_net:
driver: bridge
Expand Down
15 changes: 14 additions & 1 deletion env-example
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ HOST_PORT_MONGO=27017

################################################################################
###
### 10. Bind Docker Settings
### 10. AutoDNS Settings
###
################################################################################

Expand All @@ -637,6 +637,19 @@ HOST_PORT_MONGO=27017
###
HOST_PORT_BIND=1053

###
### The IP address to which direct all DNS resolutions.
###
### This settings really depend on where you want to access your Devilbox projects
### from your host computer's browser.
###
### If you access the Devilbox on 127.0.0.1, then set this to 127.0.0.1
### If however you're running Docker Toolbox and the Devilbox IP address is something
### like 192.168.99.100, then set it to 192.168.99.100. (Note, this is only an example)
### In case of Docker Toolbox, you will have to find out the IP address first.
###
AUTODNS_HOST_ADDRESS=127.0.0.1

###
### Add comma separated DNS server from which you want to receive DNS
### You can also add DNS servers from your LAN (if any are available)
Expand Down

0 comments on commit 7aaf2f0

Please sign in to comment.