Add HAProxy monitoring dashboard features
- Introduced a new `dashboard` frontend in HAProxy configuration to serve a real-time monitoring dashboard. - Added support for returning prebuilt `dashboard.html` for `/` or `/index.html` paths. - Updated test cases and expected outputs to accommodate the new frontend.
This commit is contained in:
parent
580c90440e
commit
67cfcf3aff
9 changed files with 186 additions and 1 deletions
103
deploy/docker/assets/etc/easyhaproxy/www/dashboard.html
Normal file
103
deploy/docker/assets/etc/easyhaproxy/www/dashboard.html
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -91,6 +91,14 @@ frontend stats
|
|||
backend srv_stats
|
||||
mode http
|
||||
server Local 127.0.0.1:{{ data_stats["port"] | default(1936) }}
|
||||
|
||||
frontend dashboard
|
||||
bind *:{{ (data_stats["port"] | default(1936) | int) + 10000 }}
|
||||
mode http
|
||||
acl is_index path /
|
||||
acl is_index path /index.html
|
||||
http-request return status 200 content-type "text/html" file /etc/easyhaproxy/www/dashboard.html if is_index
|
||||
http-request return status 404
|
||||
{% endif %}
|
||||
{% for o in data["easymapping"] -%}
|
||||
{% set mode = o["mode"] or "http" %}
|
||||
|
|
|
|||
|
|
@ -16,20 +16,46 @@ _test_session_dir = tempfile.mkdtemp(prefix="pytest_easyhaproxy_")
|
|||
os.environ["EASYHAPROXY_BASE_PATH"] = _test_session_dir
|
||||
|
||||
|
||||
_CONTAINER_ENV_VARS = [
|
||||
"HAPROXY_USERNAME",
|
||||
"HAPROXY_PASSWORD",
|
||||
"HAPROXY_STATS_PORT",
|
||||
"HAPROXY_STATS_CORS_ORIGIN",
|
||||
"HAPROXY_CUSTOMERRORS",
|
||||
"EASYHAPROXY_SSL_MODE",
|
||||
"EASYHAPROXY_LABEL_PREFIX",
|
||||
"EASYHAPROXY_LOG_LEVEL",
|
||||
"HAPROXY_LOG_LEVEL",
|
||||
"CERTBOT_LOG_LEVEL",
|
||||
"EASYHAPROXY_CERTBOT_EMAIL",
|
||||
"EASYHAPROXY_CERTBOT_SERVER",
|
||||
"EASYHAPROXY_CERTBOT_AUTOCONFIG",
|
||||
"EASYHAPROXY_CERTBOT_EAB_KID",
|
||||
"EASYHAPROXY_CERTBOT_EAB_HMAC_KEY",
|
||||
"EASYHAPROXY_PLUGINS_ENABLED",
|
||||
"EASYHAPROXY_PLUGINS_ABORT_ON_ERROR",
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture(scope="function", autouse=True)
|
||||
def reset_consts():
|
||||
"""
|
||||
Reset Consts before and after each test.
|
||||
Reset Consts and ContainerEnv environment variables before and after each test.
|
||||
|
||||
This ensures:
|
||||
1. Each test picks up the EASYHAPROXY_BASE_PATH environment variable
|
||||
2. Tests don't get permission errors trying to write to /etc/easyhaproxy/
|
||||
3. Consts path cache is cleared between tests for isolation
|
||||
4. Environment variables set by ContainerEnv._yaml_to_env don't bleed across tests
|
||||
"""
|
||||
from functions import Consts
|
||||
Consts.reset()
|
||||
for var in _CONTAINER_ENV_VARS:
|
||||
os.environ.pop(var, None)
|
||||
yield
|
||||
Consts.reset()
|
||||
for var in _CONTAINER_ENV_VARS:
|
||||
os.environ.pop(var, None)
|
||||
|
||||
|
||||
def pytest_sessionfinish(session, exitstatus):
|
||||
|
|
|
|||
|
|
@ -37,6 +37,14 @@ backend srv_stats
|
|||
mode http
|
||||
server Local 127.0.0.1:1936
|
||||
|
||||
frontend dashboard
|
||||
bind *:11936
|
||||
mode http
|
||||
acl is_index path /
|
||||
acl is_index path /index.html
|
||||
http-request return status 200 content-type "text/html" file /etc/easyhaproxy/www/dashboard.html if is_index
|
||||
http-request return status 404
|
||||
|
||||
frontend http_in_443
|
||||
bind *:443 ssl crt /etc/easyhaproxy/certs/certbot/ alpn h2,http/1.1 crt /etc/easyhaproxy/certs/haproxy/ alpn h2,http/1.1
|
||||
mode http
|
||||
|
|
|
|||
|
|
@ -45,6 +45,14 @@ backend srv_stats
|
|||
mode http
|
||||
server Local 127.0.0.1:1936
|
||||
|
||||
frontend dashboard
|
||||
bind *:11936
|
||||
mode http
|
||||
acl is_index path /
|
||||
acl is_index path /index.html
|
||||
http-request return status 200 content-type "text/html" file /etc/easyhaproxy/www/dashboard.html if is_index
|
||||
http-request return status 404
|
||||
|
||||
frontend http_in_80
|
||||
bind *:80
|
||||
mode http
|
||||
|
|
|
|||
|
|
@ -45,6 +45,14 @@ backend srv_stats
|
|||
mode http
|
||||
server Local 127.0.0.1:1937
|
||||
|
||||
frontend dashboard
|
||||
bind *:11937
|
||||
mode http
|
||||
acl is_index path /
|
||||
acl is_index path /index.html
|
||||
http-request return status 200 content-type "text/html" file /etc/easyhaproxy/www/dashboard.html if is_index
|
||||
http-request return status 404
|
||||
|
||||
frontend http_in_19901
|
||||
bind *:19901
|
||||
mode http
|
||||
|
|
|
|||
|
|
@ -35,6 +35,14 @@ backend srv_stats
|
|||
mode http
|
||||
server Local 127.0.0.1:1936
|
||||
|
||||
frontend dashboard
|
||||
bind *:11936
|
||||
mode http
|
||||
acl is_index path /
|
||||
acl is_index path /index.html
|
||||
http-request return status 200 content-type "text/html" file /etc/easyhaproxy/www/dashboard.html if is_index
|
||||
http-request return status 404
|
||||
|
||||
backend certbot_backend
|
||||
mode http
|
||||
server certbot 127.0.0.1:2080
|
||||
|
|
|
|||
|
|
@ -52,6 +52,14 @@ backend srv_stats
|
|||
mode http
|
||||
server Local 127.0.0.1:1936
|
||||
|
||||
frontend dashboard
|
||||
bind *:11936
|
||||
mode http
|
||||
acl is_index path /
|
||||
acl is_index path /index.html
|
||||
http-request return status 200 content-type "text/html" file /etc/easyhaproxy/www/dashboard.html if is_index
|
||||
http-request return status 404
|
||||
|
||||
frontend http_in_80
|
||||
bind *:80
|
||||
mode http
|
||||
|
|
|
|||
|
|
@ -45,6 +45,14 @@ backend srv_stats
|
|||
mode http
|
||||
server Local 127.0.0.1:1936
|
||||
|
||||
frontend dashboard
|
||||
bind *:11936
|
||||
mode http
|
||||
acl is_index path /
|
||||
acl is_index path /index.html
|
||||
http-request return status 200 content-type "text/html" file /etc/easyhaproxy/www/dashboard.html if is_index
|
||||
http-request return status 404
|
||||
|
||||
frontend http_in_443
|
||||
bind *:443 ssl crt /etc/easyhaproxy/certs/certbot/ alpn h2,http/1.1 crt /etc/easyhaproxy/certs/haproxy/ alpn h2,http/1.1
|
||||
mode http
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue