mirror of
https://gitlab.archlinux.org/archlinux/infrastructure.git
synced 2026-11-30 15:14:48 +01:00
Behind the HAProxy ADN every packet arrives from an allowlisted ADN IP, so an L3/L4 ban issued by fail2ban that targets the real client IP never matches. Add an opt-in L4 stream front-proxy (nginx_stream_deny) that terminates the PROXY protocol, denies banned clients by their real IP before TLS is terminated, then re-emits the PROXY protocol to loopback http listeners so the real client IP is preserved. Related-to: https://gitlab.archlinux.org/archlinux/infrastructure/-/work_items/766 Assisted-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Christian Heusel <christian@heusel.eu>
28 lines
1.1 KiB
Django/Jinja
28 lines
1.1 KiB
Django/Jinja
# Here we define which hosts we expect to receive proxied traffic from.
|
|
# If we receive traffic from one of these, we'll trust their real client IP as set by the PROXY protocol.
|
|
# Without this, we'd end up rate limiting our upstream proxies.
|
|
# See also https://nginx.org/en/docs/http/ngx_http_realip_module.html
|
|
#
|
|
# This template is rendered twice (item.server):
|
|
# - as proxy-settings-http.conf for the http{} block
|
|
# - as proxy-settings-stream.conf for the stream{} block.
|
|
|
|
{% if (nginx_proxy_protocol_upstream_host or nginx_proxy_vendor) and item.server == 'http' %}
|
|
real_ip_header proxy_protocol;
|
|
{% endif %}
|
|
|
|
{% if nginx_proxy_protocol_upstream_host %}
|
|
set_real_ip_from {{ nginx_proxy_protocol_upstream_host }};
|
|
{% endif %}
|
|
|
|
{% if item.server == 'http' and nginx_stream_deny %}
|
|
# Behind the local stream front-proxy (nginx_stream_deny): it re-emits the PROXY
|
|
# protocol from loopback, so the http{} servers only ever trust localhost here.
|
|
set_real_ip_from 127.0.0.1;
|
|
set_real_ip_from ::1;
|
|
{% elif nginx_proxy_vendor %}
|
|
{% for proxy_ip_addr in vault_proxy_vendor_trusted_ips[nginx_proxy_vendor] %}
|
|
set_real_ip_from {{ proxy_ip_addr }};
|
|
{% endfor %}
|
|
{% endif %}
|