I am trying to configure HAProxy inside a Docker host.
Using HAProxy 1.7 and Docker 1.12
My haproxy.cfg looks like this:
global
daemon
maxconn 256
resolvers docker
nameserver dns 127.0.0.1:53
defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
default-server init-addr none
frontend http-in
bind *:80
default_backend www_somedomain1_com
acl host_www_somedomain1_com hdr(host) -i somedomain1.com
acl host_www_somedomain1_com hdr(host) -i www.somedomain1.com
acl host_www_somedomain2_com hdr(host) -i www.somedomain2.com
use_backend www_somedomain1_com if host_www_somedomain1_com
use_backend www_somedomain2_com if host_www_somedomain2_com
backend www_somedomain1_com
server server1 www-somedomain1-com resolvers docker check maxconn 32
backend www_somedomain2_com
server server1 www-somedomain2-com maxconn 32 check port 80
I want to use the Docker built-in DNS system, which, in my opinion, is enabled only when using a user-defined network.
So, I am creating a network (using the default bridge driver)
docker network create mynetwork
When I launch my two docker-docker containers (my-haproxy and www-somedomain1-com), I add them to this network using the -net flag.
Docker Launch Commands:
docker run --name myhaproxy --net mynetwork -p 80:80 -d haproxy
docker run --name www-somedomain1-com --net mynetwork -d nginx
I know that Docker dns is functional, because I can allow one container to another when I jump on them in the bash shell. I cannot get the correct combination / configuration in HAProxy to enable dynamic DNS resolution.
HAProxy stats , /...
, :
- "init-addr none-default-server" haproxy .
!