1
0
Fork 0
docker-easy-haproxy/docs/docker.md
2022-08-26 20:03:11 -05:00

1.8 KiB

Docker

Setup Docker EasyHAProxy

This method will use a docker standalone installation to discover the containers and configure the HAProxy.

The only requirement is that containers and EasyHAProxy must be in the same docker network in order to HAProxy be able direct the traffic to the containers.

e.g.:

docker create network easyhaproxy

And then run the EasyHAProxy

docker run -d \
      --name easy-haproxy-container \
      -v /var/run/docker.sock:/var/run/docker.sock \
      -e EASYHAPROXY_DISCOVER="docker" \
      # + Environment Variables \
      -p 80:80 \
      -p 443:443 \
      -p 1936:1936 \
      --network easyhaproxy
    byjg/easy-haproxy

The mapping to /var/run/docker.sock is necessary to discover the docker containers and get the labels;

Running containers

To make your containers "discoverable" by EasyHAProxy that is minimum configuration you need:

docker run -d \
      -e easyhaproxy.http.host=example.org \
      -e easyhaproxy.http.port=80 \
      -e easyhaproxy.http.localport=8080 \
      --network easyhaproxy
    my/image:tag

Once the container is running EasyHAProxy will detect automatically and start to redirect all traffic from example.org:80 to your container.

You don't need to expose any port in your container.

There a list of other parameters you can to configure your container. Please follow the docker label configuration

Setup the EasyHAProxy container

You can configure the behavior of the EasyHAProxy by setup specific environment variables. To get a list of the variables please follow the docker container environment

Setup certificates with Letsencrypt

Follow this link

Setup your own certificates

Follow this link


Open source ByJG