diff --git a/states/haproxy/config.sls b/states/haproxy/config.sls
index ae25220..0c9be4d 100644
--- a/states/haproxy/config.sls
+++ b/states/haproxy/config.sls
@@ -1,5 +1,26 @@
---
{%- from "haproxy/map.jinja" import haproxy with context %}
+
+haproxy-errors-dir:
+ file.managed:
+ - name: {{ haproxy.config.dir }}/errors/{{ errorfile }}
+ - source: salt://haproxy/templates/errors/{{ errorfile }}
+ - user: {{ haproxy.config.user }}
+ - group: {{ haproxy.config.group }}
+ - mode: "0700"
+
+{% for errorfile in haproxy.errorfiles %}
+haproxy-errors-{{ errorfile }}:
+ file.managed:
+ - name: {{ haproxy.config.dir }}/errors/{{ errorfile }}
+ - source: salt://haproxy/templates/errors/{{ errorfile }}
+ - user: {{ haproxy.config.user }}
+ - group: {{ haproxy.config.group }}
+ - mode: "0600"
+ - watch_in:
+ - service: haproxy-service
+{% endfor %}
+
{% for map in haproxy.config.maps %}
haproxy-maps-{{ map }}:
file.managed:
diff --git a/states/haproxy/defaults.yaml b/states/haproxy/defaults.yaml
index 2537c1a..28ec1a1 100644
--- a/states/haproxy/defaults.yaml
+++ b/states/haproxy/defaults.yaml
@@ -14,6 +14,15 @@ haproxy:
fetchurl: https://github.com/jhunt/hatop/releases/download
version: "0.8.2"
hash: sha256=6ba2136e98b9a436488be67a54a5295f55f38090157d09df0154dda493ac5815
+ errorfiles:
+ - 400.http
+ - 403.http
+ - 404.http
+ - 408.http
+ - 500.http
+ - 502.http
+ - 503.http
+ - 504.http
config:
dir: /etc/haproxy
configfile: haproxy.cfg
diff --git a/states/haproxy/errors/400.http b/states/haproxy/errors/400.http
new file mode 100644
index 0000000..e223e38
--- /dev/null
+++ b/states/haproxy/errors/400.http
@@ -0,0 +1,9 @@
+HTTP/1.0 400 Bad request
+Cache-Control: no-cache
+Connection: close
+Content-Type: text/html
+
+
400 Bad request
+Your browser sent an invalid request.
+
+
diff --git a/states/haproxy/errors/403.http b/states/haproxy/errors/403.http
new file mode 100644
index 0000000..a67e807
--- /dev/null
+++ b/states/haproxy/errors/403.http
@@ -0,0 +1,9 @@
+HTTP/1.0 403 Forbidden
+Cache-Control: no-cache
+Connection: close
+Content-Type: text/html
+
+403 Forbidden
+Request forbidden by administrative rules.
+
+
diff --git a/states/haproxy/errors/404.http b/states/haproxy/errors/404.http
new file mode 100644
index 0000000..39b1eb0
--- /dev/null
+++ b/states/haproxy/errors/404.http
@@ -0,0 +1,9 @@
+HTTP/1.0 404 Not Found
+Cache-Control: no-cache
+Connection: close
+Content-Type: text/html
+
+404 Not Found
+Request forbidden by administrative rules. :)
+
+
diff --git a/states/haproxy/errors/408.http b/states/haproxy/errors/408.http
new file mode 100644
index 0000000..aafb130
--- /dev/null
+++ b/states/haproxy/errors/408.http
@@ -0,0 +1,9 @@
+HTTP/1.0 408 Request Time-out
+Cache-Control: no-cache
+Connection: close
+Content-Type: text/html
+
+408 Request Time-out
+Your browser didn't send a complete request in time.
+
+
diff --git a/states/haproxy/errors/500.http b/states/haproxy/errors/500.http
new file mode 100644
index 0000000..9c3be96
--- /dev/null
+++ b/states/haproxy/errors/500.http
@@ -0,0 +1,9 @@
+HTTP/1.0 500 Internal Server Error
+Cache-Control: no-cache
+Connection: close
+Content-Type: text/html
+
+500 Internal Server Error
+An internal server error occurred.
+
+
diff --git a/states/haproxy/errors/502.http b/states/haproxy/errors/502.http
new file mode 100644
index 0000000..94b35d4
--- /dev/null
+++ b/states/haproxy/errors/502.http
@@ -0,0 +1,9 @@
+HTTP/1.0 502 Bad Gateway
+Cache-Control: no-cache
+Connection: close
+Content-Type: text/html
+
+502 Bad Gateway
+The server returned an invalid or incomplete response.
+
+
diff --git a/states/haproxy/errors/503.http b/states/haproxy/errors/503.http
new file mode 100644
index 0000000..44134fd
--- /dev/null
+++ b/states/haproxy/errors/503.http
@@ -0,0 +1,24 @@
+HTTP/1.0 503 Service Unavailable
+Cache-Control: no-cache
+Connection: close
+Content-Type: text/html
+
+
+Site Maintenance
+
+
+
+ We’ll be back soon!
+
+
Sorry for the inconvenience but we’re performing some maintenance at the moment. If you need to you can always contact us, otherwise we’ll be back online shortly!
+
— The Team
+
+
+
diff --git a/states/haproxy/errors/504.http b/states/haproxy/errors/504.http
new file mode 100644
index 0000000..f925184
--- /dev/null
+++ b/states/haproxy/errors/504.http
@@ -0,0 +1,9 @@
+HTTP/1.0 504 Gateway Time-out
+Cache-Control: no-cache
+Connection: close
+Content-Type: text/html
+
+504 Gateway Time-out
+The server didn't respond in time.
+
+