1.7 KiB
1.7 KiB
Easy HAProxy
This Docker image will create dynamically the haproxy.cfg based on very simple Yaml.
Features
- Enable or disable Stats on port 1936 with custom password
- Simple mapping host => host:port
- Simple redirect host => host:port
Basic Usage
Create a yaml file in your machine called easyconfig.cfg and put the contents:
stats:
username: admin
password: senha
port: 1936 # Optional (default 1936)
customerrors: true # Optional (default false)
easymapping:
- port: 80
hosts:
host1.com.br: container:5000
host2.com.br: other:3000
redirect:
www.host1.com.br: http://host1.com.br
- port: 8080
hosts:
host3.com.br: domain:8181
Then run (remember to enable the proper ports):
docker run \
-v /path/to/local:/etc/easyconfig \
-p 80:80 \
-p 8080:8080 \
-p 1936:1936 \
--name easy-haproxy-instance \
-d byjg/easy-haproxy
Mapping custom .cfg files
Just create a folder and put files with the extension .cfg. and map the volume to the container. This will concatenate your config into the main haproxy.cfg
docker run \
/* other parameters */
-v /your/local/conf.d:/etc/haproxy/conf.d \
-d byjg/easy-haproxy
Check if your config is ok:
docker run \
/* other parameters */
-v /your/local/conf.d:/etc/haproxy/conf.d \
-byjg/easy-haproxy -c -f /etc/haproxy/haproxy.cfg
Docker Compose
version: "3.4"
services:
front:
image: byjg/easy-haproxy
volume:
- /path/to/local:/etc/easyconfig
ports:
- 80:80
- 8080:8080
- 1936:1936
Build
docker build -t byjg/easy-haproxy .