diff --git a/README.md b/README.md
index a70e441fc0bfe7c5b4914c01abe4ca6becc56f70..da0437d4414b308c007ae5d96933acf06adf145d 100644
--- a/README.md
+++ b/README.md
@@ -35,6 +35,9 @@ Role Variables
 * `haproxy_listen`
 
     A list of listen proxies.
+* `haproxy_http_errors`
+
+    A list of http-errors sections containing errorfiles for various status codes.
 
 Here is a complete list of variables:
 ```
diff --git a/tasks/configure.yml b/tasks/configure.yml
index 61a714ff99584380d3af3291edeeefdfc6ab858f..76c35eb936201cc8bd01cfc0f91ab83367dbc70d 100644
--- a/tasks/configure.yml
+++ b/tasks/configure.yml
@@ -99,6 +99,40 @@
   loop: "{{ haproxy_backends }}"
   when: haproxy_backends is defined
 
+## ASSEMBLE CONFIG - HTTP-ERRORS
+
+- name: 'Create directory for the http-errors'
+  ansible.builtin.file:
+    path: "{{ haproxy_config_dir }}/http-errors.d"
+    state: directory
+    owner: root
+    group: root
+    mode: 0755
+
+- name: "List files for the http-errors"
+  ansible.builtin.find:
+    paths: "{{ haproxy_config_dir }}/http-errors.d"
+    patterns: "*.cfg"
+  register: directory_contents
+  changed_when: false
+
+- name: "Remove unmanaged files for the http-errors"
+  ansible.builtin.file:
+    path: "{{ item.path }}"
+    state: absent
+  when: (item.path | basename) not in (haproxy_http-errors | json_query('[*].name') | map('regex_replace',  '(^.*$)', '\\1.cfg') | list)
+  loop: "{{ directory_contents.files }}"
+
+- name: 'Build up the http-errors'
+  ansible.builtin.template:
+    src: "backend.cfg"
+    dest: "{{ haproxy_config_dir }}/http-errors.d/{{ item.name }}.cfg"
+    owner: root
+    group: root
+    mode: 0644
+  loop: "{{ haproxy_http_errors }}"
+  when: haproxy_http_errors is defined
+
 ## ASSEMBLE CONFIG - LISTEN
 
 - name: 'Create directory for the listen sections'
@@ -236,6 +270,14 @@
     group: root
     mode: 0644
 
+- name: 'Assemble the http-errors configuration file'
+  ansible.builtin.assemble:
+    src: "{{ haproxy_config_dir }}/http-errors.d"
+    dest: "{{ haproxy_config_dir }}/compiled/07-http-errors.cfg"
+    owner: root
+    group: root
+    mode: 0644
+
 - name: 'Assemble the final configuration file'
   ansible.builtin.assemble:
     src: "{{ haproxy_config_dir }}/compiled"
diff --git a/templates/frontend.cfg b/templates/frontend.cfg
index 8c2ac37445fa1c49e1330bd1f6a6a0435fdf50a2..ccefa3ff445bb3eb1600b36789b76b2e42861192 100644
--- a/templates/frontend.cfg
+++ b/templates/frontend.cfg
@@ -110,6 +110,10 @@ frontend {{ item.name }} {%if item.ip is defined %}{{ item.ip }}{% endif %}{%if
 
     {%- if item.use_backend is defined -%}
     {%- for backend in item.use_backend -%}
-         use_backend {{ backend.name }} {{ backend.condition }}
+        use_backend {{ backend.name }} {{ backend.condition }}
     {% endfor -%}
     {% endif -%}
+
+    {%- if item.errorfiles -%}
+        errorfiles {% item.errorfiles %}
+    {% endif %}
diff --git a/templates/http-errors.cfg b/templates/http-errors.cfg
new file mode 100644
index 0000000000000000000000000000000000000000..c273a3afd790c24689c3a0329852f3a56598d913
--- /dev/null
+++ b/templates/http-errors.cfg
@@ -0,0 +1,7 @@
+{%- import '_macros.j2' as macros with context -%}
+
+#{{ ansible_managed }}
+http-errors {{ item.name }}
+    {% if item.errorfiles is defined %}
+    {%- for errorfile in item.errorfiles -%}
+        errorfile {{ errorfile.status }} {{ errorfile.file }}