updated haproxy state

This commit is contained in:
Paul 2023-04-28 18:11:56 +02:00
parent 9ea9bc4983
commit 37895cb84b
2 changed files with 4 additions and 3 deletions

View File

@ -5,6 +5,7 @@ haproxy:
- haproxy
- liblua5.3-dev
- lua-filesystem
- lua-socket
- libcurl4-openssl-dev
- libmaxminddb-dev
- libjansson-dev

View File

@ -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 "<html><body><p>country: %[lua.country(req.src)]</p><p>city: %[lua.city(req.src)]<p></body></html>" 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 %}