Change statistics
This commit is contained in:
parent
e20f241ab4
commit
e6d5842098
7 changed files with 59 additions and 33 deletions
20
README.md
20
README.md
|
|
@ -45,16 +45,16 @@ The mapping to `/var/run/docker.sock` is necessary to discover the docker contai
|
|||
|
||||
The environment variables will setup the HAProxy.
|
||||
|
||||
| Environment Variable | Description |
|
||||
|-------------------------------|-------------------------------------------------------------------------------|
|
||||
| EASYHAPROXY_DISCOVER | How `haproxy.cfg` will be created: `static`, `docker` or `swarm` |
|
||||
| EASYHAPROXY_LABEL_PREFIX | (Optional) The key will search for matching resources. Default: `easyhaproxy`. |
|
||||
| EASYHAPROXY_LETSENCRYPT_EMAIL | (Optional) The email will be used to request the certificate to Letsencrypt |
|
||||
| Environment Variable | Description |
|
||||
|-------------------------------|---------------------------------------------------------------------------------------------------------------|
|
||||
| EASYHAPROXY_DISCOVER | How `haproxy.cfg` will be created: `static`, `docker` or `swarm` |
|
||||
| EASYHAPROXY_LABEL_PREFIX | (Optional) The key will search for matching resources. Default: `easyhaproxy`. |
|
||||
| EASYHAPROXY_LETSENCRYPT_EMAIL | (Optional) The email will be used to request the certificate to Letsencrypt |
|
||||
| EASYHAPROXY_SSL_MODE | (Optional) `STRICT` supports only the most recent TLS version; `DEFAULT` good SSL integration with recent browsers; `LOOSE` supports all old SSL protocols for old browsers (not recommended). |
|
||||
| HAPROXY_USERNAME | (Optional) The HAProxy username to the statistics. Default: `admin` |
|
||||
| HAPROXY_PASSWORD | The HAProxy password to the statistics. If not set, it will disable stats. |
|
||||
| HAPROXY_STATS_PORT | (Optional) The HAProxy port to the statistics. Default: `1936` |
|
||||
| HAPROXY_CUSTOMERRORS | (Optional) If HAProxy will use custom HTML errors. true/false. Default: false |
|
||||
| HAPROXY_USERNAME | (Optional) The HAProxy username to the statistics. Default: `admin` |
|
||||
| HAPROXY_PASSWORD | (Optional) The HAProxy password to the statistics. If not set, statistics will be available with no password |
|
||||
| HAPROXY_STATS_PORT | (Optional) The HAProxy port to the statistics. Default: `1936`. If set to `false`, disable statistics |
|
||||
| HAPROXY_CUSTOMERRORS | (Optional) If HAProxy will use custom HTML errors. true/false. Default: `false` |
|
||||
|
||||
The environment variable `EASYHAPROXY_DISCOVER` will define where is located your containers (see below for more details):
|
||||
|
||||
|
|
@ -258,7 +258,7 @@ Caveats:
|
|||
You must expose some ports on the EasyHAProxy container and in the firewall. However, you don't need to expose the other container ports because EasyHAProxy will handle that.
|
||||
|
||||
- The ports `80` and `443`.
|
||||
- If you enable the HAProxy statistics, you must also expose the port defined in `HAPROXY_STATS_PORT` environment variable.
|
||||
- If you enable the HAProxy statistics, you must also expose the port defined in `HAPROXY_STATS_PORT` environment variable (default 1936). Be aware that statististics are enabled by default with no password.
|
||||
- Every port defined in `easyhaproxy.[definitions].port` also should be exposed.
|
||||
|
||||
e.g.
|
||||
|
|
|
|||
|
|
@ -26,23 +26,23 @@ defaults
|
|||
errorfile 504 /etc/haproxy/errors-custom/504.http
|
||||
{% endif %}
|
||||
|
||||
{% if "stats" in data %}
|
||||
{% set data_stats = data["stats"] | default({}) %}
|
||||
{% if data_stats["port"] | default(1936) | int > 0 %}
|
||||
frontend stats
|
||||
bind *:{{ data["stats"]["port"] | default(1936) }}
|
||||
bind *:{{ data_stats["port"] | default(1936) }}
|
||||
mode http
|
||||
stats enable
|
||||
stats hide-version
|
||||
stats realm Haproxy\ Statistics
|
||||
stats uri /
|
||||
stats auth {{ data["stats"]["username"] }}:{{ data["stats"]["password"] }}
|
||||
# acl is_proxystats hdr(host) -i some.host.com
|
||||
# default_backend srv_stats
|
||||
# use_backend srv_stats if is_proxystats
|
||||
{% if data_stats["password"] | default("") != "" %}
|
||||
stats auth {{ data_stats["username"] | default("admin") }}:{{ data_stats["password"] }}
|
||||
{% endif %}
|
||||
default_backend srv_stats
|
||||
|
||||
backend srv_stats
|
||||
mode http
|
||||
server Local 127.0.0.1:{{ data["stats"]["port"] | default(1936) }}
|
||||
server Local 127.0.0.1:{{ data_stats["port"] | default(1936) }}
|
||||
{% endif %}
|
||||
{% for o in data["easymapping"] -%}
|
||||
{% set mode = o["mode"] or "http" %}
|
||||
|
|
|
|||
|
|
@ -36,9 +36,6 @@ frontend stats
|
|||
stats realm Haproxy\ Statistics
|
||||
stats uri /
|
||||
stats auth admin:password
|
||||
# acl is_proxystats hdr(host) -i some.host.com
|
||||
# default_backend srv_stats
|
||||
# use_backend srv_stats if is_proxystats
|
||||
default_backend srv_stats
|
||||
|
||||
backend srv_stats
|
||||
|
|
|
|||
|
|
@ -36,9 +36,6 @@ frontend stats
|
|||
stats realm Haproxy\ Statistics
|
||||
stats uri /
|
||||
stats auth joe:s3cr3t
|
||||
# acl is_proxystats hdr(host) -i some.host.com
|
||||
# default_backend srv_stats
|
||||
# use_backend srv_stats if is_proxystats
|
||||
default_backend srv_stats
|
||||
|
||||
backend srv_stats
|
||||
|
|
|
|||
|
|
@ -19,6 +19,18 @@ defaults
|
|||
timeout client 10s
|
||||
timeout server 10m
|
||||
|
||||
frontend stats
|
||||
bind *:1936
|
||||
mode http
|
||||
stats enable
|
||||
stats hide-version
|
||||
stats realm Haproxy\ Statistics
|
||||
stats uri /
|
||||
default_backend srv_stats
|
||||
|
||||
backend srv_stats
|
||||
mode http
|
||||
server Local 127.0.0.1:1936
|
||||
|
||||
backend letsencrypt_backend
|
||||
mode http
|
||||
|
|
|
|||
|
|
@ -36,9 +36,6 @@ frontend stats
|
|||
stats realm Haproxy\ Statistics
|
||||
stats uri /
|
||||
stats auth admin:test123
|
||||
# acl is_proxystats hdr(host) -i some.host.com
|
||||
# default_backend srv_stats
|
||||
# use_backend srv_stats if is_proxystats
|
||||
default_backend srv_stats
|
||||
|
||||
backend srv_stats
|
||||
|
|
|
|||
|
|
@ -19,7 +19,10 @@ def test_parser_doesnt_crash():
|
|||
line_list = load_fixture("no-services")
|
||||
|
||||
result = {
|
||||
"customerrors": False
|
||||
"customerrors": False,
|
||||
"stats": {
|
||||
"port": "false"
|
||||
}
|
||||
}
|
||||
|
||||
cfg = easymapping.HaproxyConfigGenerator(result, CERTS_FOLDER)
|
||||
|
|
@ -38,6 +41,9 @@ def test_parser_finds_services():
|
|||
"customerrors": False,
|
||||
"letsencrypt": {
|
||||
"email": LETSENCRYPT_EMAIL
|
||||
},
|
||||
"stats": {
|
||||
"port": 0
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -65,6 +71,9 @@ def test_parser_finds_services_changed_label():
|
|||
"lookup_label": "haproxy",
|
||||
"letsencrypt": {
|
||||
"email": LETSENCRYPT_EMAIL
|
||||
},
|
||||
"stats": {
|
||||
"port": 0
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -91,6 +100,9 @@ def test_parser_finds_services_raw():
|
|||
"customerrors": False,
|
||||
"letsencrypt": {
|
||||
"email": LETSENCRYPT_EMAIL
|
||||
},
|
||||
"stats": {
|
||||
"port": 0
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -277,7 +289,10 @@ def test_parser_tcp():
|
|||
line_list = load_fixture("services-tcp")
|
||||
|
||||
result = {
|
||||
"customerrors": False
|
||||
"customerrors": False,
|
||||
"stats": {
|
||||
"port": 0
|
||||
}
|
||||
}
|
||||
|
||||
cfg = easymapping.HaproxyConfigGenerator(result, CERTS_FOLDER)
|
||||
|
|
@ -294,7 +309,10 @@ def test_parser_multi_containers():
|
|||
line_list = load_fixture("services-multi-containers")
|
||||
|
||||
result = {
|
||||
"customerrors": False
|
||||
"customerrors": False,
|
||||
"stats": {
|
||||
"port": 0
|
||||
}
|
||||
}
|
||||
|
||||
cfg = easymapping.HaproxyConfigGenerator(result, CERTS_FOLDER)
|
||||
|
|
@ -334,7 +352,10 @@ def test_parser_redirect_ssl():
|
|||
|
||||
result = {
|
||||
"customerrors": False,
|
||||
"ssl_mode": "loose"
|
||||
"ssl_mode": "loose",
|
||||
"stats": {
|
||||
"port": 0
|
||||
}
|
||||
}
|
||||
|
||||
cfg = easymapping.HaproxyConfigGenerator(result, CERTS_FOLDER)
|
||||
|
|
@ -352,7 +373,10 @@ def test_parser_ssl_strict():
|
|||
|
||||
result = {
|
||||
"customerrors": False,
|
||||
"ssl_mode": "strict"
|
||||
"ssl_mode": "strict",
|
||||
"stats": {
|
||||
"port": False
|
||||
}
|
||||
}
|
||||
|
||||
cfg = easymapping.HaproxyConfigGenerator(result, CERTS_FOLDER)
|
||||
|
|
@ -369,7 +393,7 @@ def test_parser_ssl_loose():
|
|||
|
||||
result = {
|
||||
"customerrors": False,
|
||||
"ssl_mode": "loose"
|
||||
"ssl_mode": "loose",
|
||||
}
|
||||
|
||||
cfg = easymapping.HaproxyConfigGenerator(result, CERTS_FOLDER)
|
||||
|
|
@ -387,7 +411,6 @@ def test_parser_ssl_letsencrypt():
|
|||
result = {
|
||||
"customerrors": True,
|
||||
"stats": {
|
||||
"username": "admin",
|
||||
"password": "password"
|
||||
},
|
||||
"letsencrypt": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue