Skip to content

Commit 9487e70

Browse files
authored
Merge pull request #59 from magenbrot/haproxy-stats-acls
allow ACLs in stats
2 parents d7c387f + 5c74660 commit 9487e70

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,15 @@ haproxy_default_monitor_uri:
123123

124124
# Userlist
125125
haproxy_userlist:
126-
127-
# Stats
126+
- stats-auth:
127+
groups:
128+
- "admin users admin"
129+
- "readonly users user"
130+
users:
131+
- "admin insecure-password opqrstuvw"
132+
- "user insecure-password abcdefghi"
133+
134+
# Stats with HTTP Basic Auth and a single user
128135
haproxy_stats: true
129136
haproxy_stats_address: '*'
130137
haproxy_stats_port: 9001
@@ -145,6 +152,23 @@ haproxy_stats_timeouts:
145152
- connect 100s
146153
- queue 100s
147154

155+
# Stats with HTTP Basic Auth using an userlist
156+
haproxy_stats: true
157+
haproxy_stats_address: "::"
158+
haproxy_stats_port: 8081
159+
haproxy_stats_ssl: false
160+
haproxy_stats_uri: /stats
161+
haproxy_stats_auth:
162+
haproxy_stats_acls:
163+
- "AUTH http_auth(stats-auth)"
164+
- "AUTH_ADMIN http_auth_group(stats-auth) admin"
165+
haproxy_stats_options:
166+
- refresh 5s
167+
- show-legends
168+
- show-node
169+
- http-request auth unless AUTH
170+
- admin if AUTH_ADMIN
171+
148172
# SSL
149173
haproxy_ssl_certificate: /etc/ssl/uoi.io/uoi.io.pem
150174
haproxy_ssl_options: no-sslv3 no-tls-tickets force-tlsv12

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ haproxy_stats_address: '*'
8989
haproxy_stats_port: 9001
9090
haproxy_stats_ssl: false
9191
haproxy_stats_auth: true
92+
haproxy_stats_acls: []
9293
haproxy_stats_user: haproxy-stats
9394
haproxy_stats_password: B1Gp4sSw0rD!!
9495
haproxy_stats_uri: /

templates/etc/haproxy/haproxy-stats.cfg.j2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ listen stats
1010
{% endif %}
1111
mode http
1212
maxconn 10
13+
{% if haproxy_stats_acls is defined and haproxy_stats_acls|length %}
14+
{% for acl in haproxy_stats_acls %}
15+
acl {{ acl }}
16+
{% endfor %}
17+
{% endif %}
1318
stats enable
1419
{% for opt in haproxy_stats_options %}
1520
stats {{ opt }}

0 commit comments

Comments
 (0)