diff --git a/docker/haproxy/Dockerfile b/docker/haproxy/Dockerfile new file mode 100644 index 0000000..d6b418a --- /dev/null +++ b/docker/haproxy/Dockerfile @@ -0,0 +1,7 @@ +FROM alpine +RUN apk update +RUN apk add haproxy +RUN mkdir /etc/haproxy +ADD haproxy.cfg /etc/haproxy/haproxy.cfg +VOLUME /etc/haproxy/ +CMD /usr/sbin/haproxy -fdV /etc/haproxy/haproxy.cfg diff --git a/docker/haproxy/haproxy.cfg b/docker/haproxy/haproxy.cfg new file mode 100644 index 0000000..515b859 --- /dev/null +++ b/docker/haproxy/haproxy.cfg @@ -0,0 +1,46 @@ + +#--------------------------------------------------------------------- +# Global settings +#--------------------------------------------------------------------- +global + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + #daemon + debug + +#--------------------------------------------------------------------- +# common defaults that all the 'listen' and 'backend' sections will +# use if not designated in their block +#--------------------------------------------------------------------- +defaults + mode http + option http-server-close + option forwardfor except 127.0.0.0/8 + option redispatch + retries 3 + timeout http-request 10s + timeout queue 1m + timeout connect 10s + timeout client 1m + timeout server 1m + timeout http-keep-alive 10s + timeout check 10s + maxconn 3000 + +#--------------------------------------------------------------------- +# main frontend which proxys to the backends +#--------------------------------------------------------------------- +frontend main + bind *:80 + default_backend app + +#--------------------------------------------------------------------- +# round robin balancing between the various backends +#--------------------------------------------------------------------- +backend app + balance roundrobin + server app1 192.168.41.1:80 check + server app2 192.168.41.2:80 check + server app3 192.168.41.3:80 check