Added Custom Config
This commit is contained in:
parent
4aa00d15fa
commit
de0c7a93b8
5 changed files with 50 additions and 8 deletions
|
|
@ -2,7 +2,8 @@ FROM haproxy:1.8-alpine
|
|||
|
||||
RUN apk add --no-cache bash
|
||||
|
||||
COPY entrypoint.sh /
|
||||
COPY *.sh /
|
||||
COPY conf.d /etc/haproxy/conf.d
|
||||
COPY assets/errors-custom/* /etc/haproxy/errors-custom/
|
||||
|
||||
ENTRYPOINT [ "/entrypoint.sh" ]
|
||||
|
|
|
|||
29
README.md
29
README.md
|
|
@ -5,7 +5,10 @@ This Docker image will create dynamically the `haproxy.cfg` based on the argumen
|
|||
## Features
|
||||
|
||||
- Enable or disable Stats on port 1936 with custom password
|
||||
- Add a mapping from a host to another
|
||||
- Add a mapping from a host to another based on Environment Variables
|
||||
- Dont need to setup .cfg file
|
||||
- You can add custom .cfg file by mapping the `conf.d` folder
|
||||
|
||||
|
||||
## Usages
|
||||
|
||||
|
|
@ -28,8 +31,30 @@ docker run \
|
|||
-e LB_STATS_USER=admin \
|
||||
-e LB_STATS_PASS=mypassword \
|
||||
-e LB_HOSTS="my.domain.com container1:8080 other.domain.com other:7000" \
|
||||
-p 80:80 \
|
||||
--name easy-haproxy-instance \
|
||||
-t -d byjg/easy-haproxy
|
||||
-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
|
||||
|
||||
```bash
|
||||
docker run \
|
||||
/* other parameters */
|
||||
-v /your/local/conf.d:/etc/haproxy/conf.d \
|
||||
-d byjg/easy-haproxy
|
||||
```
|
||||
|
||||
Check if your config is ok:
|
||||
|
||||
```bash
|
||||
docker run \
|
||||
/* other parameters */
|
||||
-v /your/local/conf.d:/etc/haproxy/conf.d \
|
||||
-byjg/easy-haproxy -c -f /etc/haproxy/haproxy.cfg
|
||||
```
|
||||
|
||||
|
||||
|
|
|
|||
1
conf.d/00-simple-comment.cfg
Normal file
1
conf.d/00-simple-comment.cfg
Normal file
|
|
@ -0,0 +1 @@
|
|||
# Simple file include
|
||||
3
conf.d/README.md
Normal file
3
conf.d/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Custom HAProxy
|
||||
|
||||
Put files .cfg to be included in the configuration
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
echo " ______ _ _ _____ "
|
||||
|
|
@ -14,6 +15,8 @@ echo ""
|
|||
defaults() {
|
||||
echo "
|
||||
defaults
|
||||
log global
|
||||
|
||||
timeout connect 3s
|
||||
timeout client 10s
|
||||
timeout server 10m
|
||||
|
|
@ -114,13 +117,22 @@ do
|
|||
done
|
||||
|
||||
# Write
|
||||
defaults > $HAPROXY_CFG
|
||||
defaults > ${HAPROXY_CFG}
|
||||
if [ ! -z "${LB_STATS_USER}" ]
|
||||
then
|
||||
stats ${LB_STATS_USER} ${LB_STATS_PASS} >> $HAPROXY_CFG
|
||||
stats ${LB_STATS_USER} ${LB_STATS_PASS} >> ${HAPROXY_CFG}
|
||||
fi
|
||||
frontend "$FRONTEND" >> $HAPROXY_CFG
|
||||
backend "$BACKEND" >> $HAPROXY_CFG
|
||||
frontend "$FRONTEND" >> ${HAPROXY_CFG}
|
||||
backend "$BACKEND" >> ${HAPROXY_CFG}
|
||||
|
||||
# More
|
||||
for config in `ls /etc/haproxy/conf.d/*.cfg`
|
||||
do
|
||||
echo Loading extra config: ${config}
|
||||
cat ${config} >> ${HAPROXY_CFG}
|
||||
done
|
||||
|
||||
echo
|
||||
|
||||
/sbin/syslogd -O /proc/1/fd/1
|
||||
/docker-entrypoint.sh "$@"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue