Merge remote-tracking branch 'origin/2.2' into 2.2
This commit is contained in:
commit
b753e2c756
8 changed files with 170 additions and 21 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,3 +3,4 @@
|
||||||
venv
|
venv
|
||||||
.docker_data
|
.docker_data
|
||||||
__pycache__
|
__pycache__
|
||||||
|
.pytest_cache
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
FROM haproxy:2.1-alpine
|
FROM alpine:3.14
|
||||||
|
|
||||||
WORKDIR /scripts
|
WORKDIR /scripts
|
||||||
|
|
||||||
RUN apk add --no-cache bash python3 py-yaml supervisor docker \
|
RUN apk add --no-cache haproxy bash python3 py3-pip py-yaml supervisor docker \
|
||||||
&& ln -s /usr/bin/python3 /usr/bin/python
|
&& ln -s /usr/bin/python3 /usr/bin/python
|
||||||
|
|
||||||
COPY requirements.txt /scripts
|
COPY requirements.txt /scripts
|
||||||
|
|
||||||
RUN pip3 install --upgrade pip \
|
RUN pip3 install --upgrade pip \
|
||||||
&& pip install -r requirements.txt
|
&& pip install -r requirements.txt
|
||||||
|
|
||||||
|
|
|
||||||
34
README.md
34
README.md
|
|
@ -3,7 +3,7 @@
|
||||||
This Docker image will create dynamically the `haproxy.cfg` based on the labels defined in docker containers or from
|
This Docker image will create dynamically the `haproxy.cfg` based on the labels defined in docker containers or from
|
||||||
a simple Yaml instead docker
|
a simple Yaml instead docker
|
||||||
|
|
||||||
# Features
|
## Features
|
||||||
|
|
||||||
- Enable or disable Stats on port 1936 with custom password
|
- Enable or disable Stats on port 1936 with custom password
|
||||||
- Discover and setup haproxy from Docker Tag
|
- Discover and setup haproxy from Docker Tag
|
||||||
|
|
@ -11,7 +11,7 @@ a simple Yaml instead docker
|
||||||
- Setup HAProxy CFG from a Yaml file.
|
- Setup HAProxy CFG from a Yaml file.
|
||||||
|
|
||||||
|
|
||||||
# Basic Usage
|
## Basic Usage
|
||||||
|
|
||||||
The Easy HAProxy will create the `haproxy.cfg` automatically based on the containers or from a YAML provided.
|
The Easy HAProxy will create the `haproxy.cfg` automatically based on the containers or from a YAML provided.
|
||||||
|
|
||||||
|
|
@ -31,7 +31,6 @@ The mapping to `/var/run/docker.sock` is necessary to discover the docker contai
|
||||||
|
|
||||||
The environment variables will setup the HAProxy.
|
The environment variables will setup the HAProxy.
|
||||||
|
|
||||||
{:.table}
|
|
||||||
| Environment Variable | Description |
|
| Environment Variable | Description |
|
||||||
|----------------------|-------------------------------------------------------------------------------|
|
|----------------------|-------------------------------------------------------------------------------|
|
||||||
| DISCOVER | How `haproxy.cfg` will be created: `static`, `docker` or `swarm` |
|
| DISCOVER | How `haproxy.cfg` will be created: `static`, `docker` or `swarm` |
|
||||||
|
|
@ -47,7 +46,7 @@ The environment variable `DISCOVER` will define where is located your containers
|
||||||
- swarm
|
- swarm
|
||||||
- static
|
- static
|
||||||
|
|
||||||
# DISCOVER: docker
|
## DISCOVER: docker
|
||||||
|
|
||||||
This method will use a regular docker installation to discover the containers and configure the HAProxy.
|
This method will use a regular docker installation to discover the containers and configure the HAProxy.
|
||||||
|
|
||||||
|
|
@ -65,7 +64,7 @@ docker run --network easyhaproxy byjg/easyhaproxy
|
||||||
docker run --network easyhaproxy myimage
|
docker run --network easyhaproxy myimage
|
||||||
```
|
```
|
||||||
|
|
||||||
# DISCOVER: swarm
|
## DISCOVER: swarm
|
||||||
|
|
||||||
This method requires a functional Docker Swarm Cluster. The system will search for the labels in all containers on all
|
This method requires a functional Docker Swarm Cluster. The system will search for the labels in all containers on all
|
||||||
swarm nodes.
|
swarm nodes.
|
||||||
|
|
@ -74,19 +73,18 @@ The discover will occur every minute.
|
||||||
|
|
||||||
Important: easyhaproxy needs to be in the same network of the containers or otherwise will not access.
|
Important: easyhaproxy needs to be in the same network of the containers or otherwise will not access.
|
||||||
|
|
||||||
## Tags to be attached in the Docker Container
|
### Tags to be attached in the Docker Container (Swarm or Docker)
|
||||||
|
|
||||||
{:.table}
|
| Tag | Description | Example |
|
||||||
| Tag | Description |
|
|---------------------------------------------|---------------------------------------------------------------------------------------------------------|--------------|
|
||||||
|---------------------------------------------|---------------------------------------------------------------------------------------------------------|
|
| com.byjg.easyhaproxy.definitions | A Comma delimited list with the definitions. Each name requires the definition of the parameters below. | http,https |
|
||||||
| com.byjg.easyhaproxy.definitions | A Comma delimited list with the definitions. Each name requires the definition of the parameters below. |
|
| com.byjg.easyhaproxy.mode.[definition] | (Optional) Is this http or tcp mode in HAProxy. (Defaults to http) | http |
|
||||||
| com.byjg.easyhaproxy.mode.[definition] | (Optional) Is this http or tcp mode in HAProxy. (Defaults to http) |
|
| com.byjg.easyhaproxy.port.[definition] | (Optional) What is the port that the HAProxy will listen to. (Defaults to 80) | 80 |
|
||||||
| com.byjg.easyhaproxy.port.[definition] | (Optional) What is the port that the HAProxy will listen to. (Defaults to 80) |
|
| com.byjg.easyhaproxy.localport.[definition] | (Optional) What is the port that the container is listening. (Defaults to 80) | 8080 |
|
||||||
| com.byjg.easyhaproxy.localport.[definition] | (Optional) What is the port that the container is listening. (Defaults to 80) |
|
| com.byjg.easyhaproxy.host.[definition] | What is the host that the HAProxy will listen to. | somehost.com |
|
||||||
| com.byjg.easyhaproxy.host.[definition] | What is the host that the HAProxy will listen to. |
|
| com.byjg.easyhaproxy.redirect.[definition] | (Optional) Host redirects from connections in the port defined above. | foo.com--https://bla.com,bar.com--https://bar.org |
|
||||||
| com.byjg.easyhaproxy.redirect.[definition] | (Optional) Host redirects from connections in the port defined above. |
|
| com.byjg.easyhaproxy.sslcert.[definition] | (Optional) Cert PEM Base64 encoded. | |
|
||||||
| com.byjg.easyhaproxy.sslcert.[definition] | (Optional) Cert PEM Base64 encoded. |
|
| com.byjg.easyhaproxy.health-check.[definition] | (Optional) `ssl`, enable health check via SSL in `mode tcp` (Defaults to "empty") | |
|
||||||
| com.byjg.easyhaproxy.health-check.[definition] | (Optional) `ssl`, enable health check via SSL in `mode tcp` (Defaults to "empty") |
|
|
||||||
|
|
||||||
Note: if you are deploying a stack set labels at the `deploy` level:
|
Note: if you are deploying a stack set labels at the `deploy` level:
|
||||||
|
|
||||||
|
|
@ -150,7 +148,7 @@ docker run \
|
||||||
-l com.byjg.easyhaproxy.redirect.<defintion>=www.byjg.com.br--http://byjg.com.br,byjg.com--http://byjg.com.br
|
-l com.byjg.easyhaproxy.redirect.<defintion>=www.byjg.com.br--http://byjg.com.br,byjg.com--http://byjg.com.br
|
||||||
```
|
```
|
||||||
|
|
||||||
# DISCOVER: static
|
## DISCOVER: static
|
||||||
|
|
||||||
This method expects a YAML file to setup the `haproxy.cfg`
|
This method expects a YAML file to setup the `haproxy.cfg`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
source /scripts/haproxy-reload.sh initial
|
source /scripts/haproxy-reload.sh initial
|
||||||
|
|
||||||
/usr/local/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /var/run/haproxy.sock
|
/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /var/run/haproxy.sock
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
sleep 60
|
sleep 60
|
||||||
|
|
|
||||||
32
examples/docker/docker-compose.yml
Normal file
32
examples/docker/docker-compose.yml
Normal file
File diff suppressed because one or more lines are too long
17
examples/static/config.yml
Normal file
17
examples/static/config.yml
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
stats:
|
||||||
|
username: admin
|
||||||
|
password: password
|
||||||
|
port: 1936 # Optional (default 1936)
|
||||||
|
|
||||||
|
customerrors: true # Optional (default false)
|
||||||
|
|
||||||
|
easymapping:
|
||||||
|
- port: 80
|
||||||
|
redirect:
|
||||||
|
host1.local: https://host1.local
|
||||||
|
www.host1.local: https://host1.local
|
||||||
|
|
||||||
|
- port: 443
|
||||||
|
ssl_cert: /etc/certs/host1.local.pem
|
||||||
|
hosts:
|
||||||
|
host1.local: container:8080
|
||||||
18
examples/static/docker-compose.yml
Normal file
18
examples/static/docker-compose.yml
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
version: "3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
haproxy:
|
||||||
|
image: byjg/easy-haproxy
|
||||||
|
volumes:
|
||||||
|
- ./config.yml:/etc/haproxy/easyconfig.yml
|
||||||
|
- ./host1.local.pem:/etc/certs/host1.local.pem
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
environment:
|
||||||
|
DISCOVER: static
|
||||||
|
ports:
|
||||||
|
- "80:80/tcp"
|
||||||
|
- "443:443/tcp"
|
||||||
|
- "1936:1936/tcp"
|
||||||
|
|
||||||
|
container:
|
||||||
|
image: byjg/static-httpserver
|
||||||
82
examples/static/host1.local.pem
Normal file
82
examples/static/host1.local.pem
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIFDTCCAvWgAwIBAgIURi+w1ZVgeedTlNIAwqQBMJv6dXswDQYJKoZIhvcNAQEL
|
||||||
|
BQAwFjEUMBIGA1UEAwwLaG9zdDEubG9jYWwwHhcNMjEwODEwMTg0OTA2WhcNMzEw
|
||||||
|
ODA4MTg0OTA2WjAWMRQwEgYDVQQDDAtob3N0MS5sb2NhbDCCAiIwDQYJKoZIhvcN
|
||||||
|
AQEBBQADggIPADCCAgoCggIBAMBDAhLAygJuaW6w6ffigzTAAGXpmEz0tIxn1k4Z
|
||||||
|
x5wN5rpv/qu0QMYz+Av2u1eOKEKZeaFRVpT0r93dX7IvbEZHt25GPiBvlLGqhjKR
|
||||||
|
PnSk/7U8XmsnttUAV7rVEK1UrdFw8/IwriQC+dhr0mnYfSDMkvBoMFpdhVNTrbAZ
|
||||||
|
1TB6rQjE7Ar0Mt8my96XJmwrcjK2Tj+E2rgPIUz1e5cekFYIDSBatmw+3+vr+T5x
|
||||||
|
FNFkJ2o30W5o8ZflCJJzrVaihqQics6ZKDgpf7iqXMFiwWIlhdQpGvx5Gf/KFTK9
|
||||||
|
UaOnRZz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ImszZiMyHHG8VGGmPh88n7
|
||||||
|
wVxb0gV0P4RMrcMLdeTdn55YQr1CqBr34eB6ol6AsbTm3VzBHRVmFNksl1o5JB5t
|
||||||
|
tXLgF/G8/rzJ/4m1PaVuxrB7DxUmIk8EPbSIVkvZvd7LBzKwQ6IfVaucewHfEajQ
|
||||||
|
VIiexSMiFc7lw3KnxjOHZjf6FM9VYg3No++GdC99s7LkIuJwAMLNqTQ7Hvhn7YvP
|
||||||
|
4FlSIgc6xj0YkGZEQlb5o/5nauEqQU0ABgw6jtI4NxrNLT6cp7CO4M0xIDEg/3YD
|
||||||
|
aA==
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
-----BEGIN PRIVATE KEY-----
|
||||||
|
MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQDAQwISwMoCbmlu
|
||||||
|
sOn34oM0wABl6ZhM9LSMZ9ZOGcecDea6b/6rtEDGM/gL9rtXjihCmXmhUVaU9K/d
|
||||||
|
3V+yL2xGR7duRj4gb5SxqoYykT50pP+1PF5rJ7bVAFe61RCtVK3RcPPyMK4kAvnY
|
||||||
|
a9Jp2H0gzJLwaDBaXYVTU62wGdUweq0IxOwK9DLfJsvelyZsK3Iytk4/hNq4DyFM
|
||||||
|
9XuXHpBWCA0gWrZsPt/r6/k+cRTRZCdqN9FuaPGX5QiSc61WooakInLOmSg4KX+4
|
||||||
|
qlzBYsFiJYXUKRr8eRn/yhUyvVGjp0Wc/1/tgnmwBWkx0d5Pz2KaVk4AQQbkb5aQ
|
||||||
|
sPsHZ5JrXgtEkERfdUFla+3o6OymjpRiOVbbzFLFr03gGZqWspiGgExE7jiWmNCV
|
||||||
|
NdTpi3g/Qzo+RNkkO6iF/6RXKcacxuY+HPjJYL8T9lQJDU3gFwmmIjwUB+WWYNBx
|
||||||
|
NlpwdSoS0RZR3eIh0A9hiecjf+nwhQX2XyknivCWrsMYFpK2udznA6v5infgwP3S
|
||||||
|
vv67hu7asFYCGtOBzqZcz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lschaLd1EYlEZa2BAoIBAQCye25T4TV5MJFv0zuZ
|
||||||
|
MGuNg1Sc/O4Fkn2fEUOceWjhwUBH4cPjT/f1DwWDsNaJ9NRbxCr5931OArPDc5c8
|
||||||
|
A404+Y4jM5RBQkKZli94tHAod+jc9UBB6TUvJll59SlMwC9679wS21ZOKnfPKGCX
|
||||||
|
SsZGQEsZxf6ZhhsHgXJ3gl/lzUJPmPeOA5YVR+Od9/09KIFFTojSfoynhVCuKx49
|
||||||
|
xb4uVYn2HOJ4xJ0fPTghdCHMvrmXeeQRjvb88eaNmqVUEHHFFtgb4fklA5fE7RTx
|
||||||
|
BhliRDBwZ7bUkINK6yVk9n6BTns5mMvRLmgdnJpYvE7KC02LTbZb3I+j8C0ZUa+N
|
||||||
|
qy7DAoIBAAieribS7WUcl2aBlkm5+W7qNm/INm5zvnoSPo6V3wa5hs6f9+C/kbdF
|
||||||
|
87jQPA/YFe3uR2sAJ7slX5euZK8WmfpFmgzlu0sEz81MLQ/WypZtZytyVtWzB2Pu
|
||||||
|
XCW1tdSH9eI2BmhXgokHNTM48Nk/xOENrP/seXrIx5LK0hnDHZotu/z6+YSkB9hF
|
||||||
|
cm2fZygD1dMLX6liRimxyFY+dICJNB95JifTLWYnWeGddkwPtXUeGXE1olzvNkLD
|
||||||
|
zMzE09uhkx/lRJnteOBEZaf80OB/09Oi9b9/rxY59dwsH6GaxLoTfEKuPnvBVMNR
|
||||||
|
YkU14WzQKleFkiBJI9lVvnfgGnOlgg0=
|
||||||
|
-----END PRIVATE KEY-----
|
||||||
Loading…
Add table
Add a link
Reference in a new issue