diff --git a/states/haproxy/defaults.yaml b/states/haproxy/defaults.yaml index 703b191..28c051b 100644 --- a/states/haproxy/defaults.yaml +++ b/states/haproxy/defaults.yaml @@ -5,6 +5,7 @@ haproxy: - haproxy - liblua5.3-dev - lua-filesystem + - lua-socket - libcurl4-openssl-dev - libmaxminddb-dev - libjansson-dev diff --git a/states/haproxy/templates/haproxy.cfg.j2 b/states/haproxy/templates/haproxy.cfg.j2 index ff9d0b8..e86b22e 100644 --- a/states/haproxy/templates/haproxy.cfg.j2 +++ b/states/haproxy/templates/haproxy.cfg.j2 @@ -24,7 +24,7 @@ {%- macro httpendpoints(servers=[], check=True, disabled=False) -%} {%- for server in servers %} - server {{ server.name }} {{ server.name }}:{{ server.port }}{{ " " + httpcheckrules(inter=server.inter|default("2s"), fall=server.fall|default(5), rise=server.rise|default(5)) if check }}{{ " " + httpsslrules() if server.ssl|default(False) }}{{ " disabled" if server.disabled|default(False) }}{{ " send-proxy" if server.proxy|default(False) }} + server {{ server.name }} {{ server.name }}:{{ server.port }}{{ " " + httpcheckrules(inter=server.inter|default("2s"), fall=server.fall|default(5), rise=server.rise|default(5)) if check }}{{ " " + httpsslrules() if server.ssl|default(False) }}{{ " disabled" if server.disabled|default(False) }}{{ " send-proxy" if server.proxy|default(False) }}{{ " on-marked-down shutdown-sessions" if server.killsessions|default(False) }} {%- endfor %} {%- endmacro -%} @@ -163,7 +163,7 @@ frontend https from {{ haproxy.config.namespace }} acl path_host path_dir /host acl path_date path_dir /date acl path_srchash path /srchash - acl path_country path /country + acl path_location path /location ## Basic rules http-request set-var(txn.random) rand,mul(5) @@ -185,7 +185,7 @@ frontend https from {{ haproxy.config.namespace }} {%- if haproxy.config.geoip.enabled %} # GeoIP http-request set-var(txn.country) lua.country(req.src) - http-request return content-type text/plain lf-string "%[var(txn.country)]" if path_country + http-request return status 200 content-type "text/html; charset=utf-8" lf-string "

country: %[lua.country(req.src)]

city: %[lua.city(req.src)]

" if self_host path_location acl allowed_country var(txn.country),map_str(/etc/haproxy/maps/countries,OK) OK http-response deny deny_status 451 content-type text/plain string "Denied" if !allowed_country !internal {%- endif %}