From 3bbea2d6ca868c06f0b0ce5e25ac32fa1deebc8f Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Tue, 5 May 2026 15:41:03 +0200 Subject: [PATCH 1/2] feat(config): support httperrors Signed-off-by: Georg Pfuetzenreuter --- haproxy/templates/haproxy.jinja | 8 ++++++++ pillar.example | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/haproxy/templates/haproxy.jinja b/haproxy/templates/haproxy.jinja index 9ad1544..8ee563b 100644 --- a/haproxy/templates/haproxy.jinja +++ b/haproxy/templates/haproxy.jinja @@ -160,6 +160,14 @@ defaults errorfile {{ errorfile_name }} {{ errorfile }} {%- endfor %} {% endif %} + +{%- for error_name, error_files in salt['pillar.get']('haproxy:httperrors', {}) | dictsort %} +http-errors {{ error_name }} + {%- for code, file in error_files | dictsort %} + errorfile {{ code }} {{ file }} + {%- endfor %} +{%- endfor %} + {%- if salt['pillar.get']('haproxy:resolvers') %} diff --git a/pillar.example b/pillar.example index 3a05a85..1ca6473 100644 --- a/pillar.example +++ b/pillar.example @@ -90,6 +90,10 @@ haproxy: 503: /etc/haproxy/errors/503.http 504: /etc/haproxy/errors/504.http + httperrors: + corp: + 503: /etc/haproxy/errors/corp/503.http + resolvers: local_dns: options: @@ -171,6 +175,9 @@ haproxy: - scheme https if !{ ssl_fc } reqadds: - "X-Forwarded-Proto:\\ http" + httpresponses: + - return: + - status 503 errorfiles corp if { status 503 } default_backend: www-backend # www-https: From e1263b0ff37d04e53cbdacaa0ea1185e1ec035b1 Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Thu, 7 May 2026 15:45:03 +0200 Subject: [PATCH 2/2] feat(config): support errorfiles Signed-off-by: Georg Pfuetzenreuter --- haproxy/templates/haproxy.jinja | 9 +++++++++ pillar.example | 1 + 2 files changed, 10 insertions(+) diff --git a/haproxy/templates/haproxy.jinja b/haproxy/templates/haproxy.jinja index 8ee563b..bed02bc 100644 --- a/haproxy/templates/haproxy.jinja +++ b/haproxy/templates/haproxy.jinja @@ -320,6 +320,9 @@ listen {{ listener.get('name', listener_name) }} {%- endfor %} {%- endif %} {%- endif %} + {%- if 'errorfiles' in listener %} + errorfiles {{ listener.errorfiles }} + {%- endif %} {%- if 'default_backend' in listener %} default_backend {{ listener.default_backend }} {%- endif %} @@ -480,6 +483,9 @@ frontend {{ frontend.get('name', frontend_name) }} {%- endfor %} {%- endif %} {%- endif %} + {%- if 'errorfiles' in frontend %} + errorfiles {{ frontend.errorfiles }} + {%- endif %} {%- if 'default_backend' in frontend %} default_backend {{ frontend.default_backend }} {%- endif %} @@ -495,6 +501,9 @@ frontend {{ frontend.get('name', frontend_name) }} #------------------ {%- for backend_name, backend in salt['pillar.get']('haproxy:backends', {})|dictsort %} backend {{ backend.get('name', backend_name) }} + {%- if 'errorfiles' in backend %} + errorfiles {{ backend.errorfiles }} + {%- endif %} {%- if 'mode' in backend %} mode {{ backend.mode }} {%- endif %} diff --git a/pillar.example b/pillar.example index 1ca6473..76e24f1 100644 --- a/pillar.example +++ b/pillar.example @@ -175,6 +175,7 @@ haproxy: - scheme https if !{ ssl_fc } reqadds: - "X-Forwarded-Proto:\\ http" + errorfiles: corp httpresponses: - return: - status 503 errorfiles corp if { status 503 }