Skip to content
Snippets Groups Projects
Commit c0e9ed1a authored by jurgenhaas's avatar jurgenhaas
Browse files

New option to require http auth for all requests if not from a private IP

parent c1d2fe94
No related branches found
No related tags found
No related merge requests found
......@@ -85,6 +85,16 @@
- 'blacklist.agent'
notify: "Check HAProxy Config"
- name: "Update private ips"
template:
src='privatelist.ip.jinja2'
dest='/etc/haproxy/privatelist.ip'
owner='root'
group='root'
mode='644'
when: haproxy_private is defined
notify: "Check HAProxy Config"
- name: "Create config file"
template:
src='haproxy_cfg.jinja2'
......
......@@ -49,10 +49,22 @@ userlist kibana
user {{ user.username }} insecure-password '{{ user.password }}'
{% endfor %}
{% endif %}
{% if haproxy_private is defined %}
userlist notprivate
{% for user in haproxy_private.auth %}
user {{ user.username }} insecure-password '{{ user.password }}'
{% endfor %}
{% endif %}
frontend http_in
bind *:80
http-request del-header Proxy
{% if haproxy_private is defined %}
acl privateip src -f /etc/haproxy/privatelist.ip
acl private_auth http_auth(notprivate) if !privateip
http-request auth realm notprivate if !privateip !private_auth
{% endif %}
acl blockedip src -f /etc/haproxy/blacklist.ip
http-request deny if blockedip
acl blockedreferer hdr_sub(referer) -i -f /etc/haproxy/blacklist.referer
......@@ -170,6 +182,11 @@ frontend http_in
frontend https_in_{{ cert.ip }}
bind {{ cert.ip }}:443 ssl crt /etc/haproxy/certs/{{ cert.file }} no-sslv3
http-request del-header Proxy
{% if haproxy_private is defined %}
acl privateip src -f /etc/haproxy/privatelist.ip
acl private_auth http_auth(notprivate) if !privateip
http-request auth realm notprivate if !privateip !private_auth
{% endif %}
acl blockedip src -f /etc/haproxy/blacklist.ip
http-request deny if blockedip
acl blockedreferer hdr_sub(referer) -i -f /etc/haproxy/blacklist.referer
......
{% for ip in haproxy_private.ip %}
{{ ip }}
{% endfor %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment