diff --git a/plugins/nginx-vhosts/functions b/plugins/nginx-vhosts/functions
index 4778d266d..b41a69921 100755
--- a/plugins/nginx-vhosts/functions
+++ b/plugins/nginx-vhosts/functions
@@ -289,6 +289,7 @@ nginx_build_config() {
local SIGIL_PARAMS=(-f $NGINX_TEMPLATE APP="$APP" DOKKU_ROOT="$DOKKU_ROOT"
NOSSL_SERVER_NAME="$NOSSL_SERVER_NAME"
DOKKU_APP_LISTENERS="$DOKKU_APP_LISTENERS"
+ DOKKU_LIB_ROOT="$DOKKU_LIB_ROOT"
PASSED_LISTEN_IP_PORT="$PASSED_LISTEN_IP_PORT"
SPDY_SUPPORTED="$SPDY_SUPPORTED"
HTTP2_SUPPORTED="$HTTP2_SUPPORTED"
diff --git a/plugins/nginx-vhosts/install b/plugins/nginx-vhosts/install
index bc0ba7905..39b0d5cc6 100755
--- a/plugins/nginx-vhosts/install
+++ b/plugins/nginx-vhosts/install
@@ -56,6 +56,13 @@ chgrp -R adm /var/log/nginx
gpasswd -M "" dokku
[[ -f /etc/logrotate.d/nginx ]] && sed -i -e 's/create 0640 www-data dokku/create 0640 www-data adm/g' /etc/logrotate.d/nginx
+# Create nginx error templates
+mkdir -p "${DOKKU_LIB_ROOT}/data/nginx-vhosts/dokku-errors"
+cp "${PLUGIN_CORE_AVAILABLE_PATH}/nginx-vhosts/templates/400-error.html" "${DOKKU_LIB_ROOT}/data/nginx-vhosts/dokku-errors/400-error.html"
+cp "${PLUGIN_CORE_AVAILABLE_PATH}/nginx-vhosts/templates/404-error.html" "${DOKKU_LIB_ROOT}/data/nginx-vhosts/dokku-errors/404-error.html"
+cp "${PLUGIN_CORE_AVAILABLE_PATH}/nginx-vhosts/templates/500-error.html" "${DOKKU_LIB_ROOT}/data/nginx-vhosts/dokku-errors/500-error.html"
+
+
# patch broken nginx 1.8.0 logrotate
[[ -f /etc/logrotate.d/nginx ]] && sed -i -e 's/invoke-rc.d/service/g' /etc/logrotate.d/nginx
diff --git a/plugins/nginx-vhosts/templates/400-error.html b/plugins/nginx-vhosts/templates/400-error.html
new file mode 100644
index 000000000..2f4c79b9c
--- /dev/null
+++ b/plugins/nginx-vhosts/templates/400-error.html
@@ -0,0 +1,32 @@
+
+
+
+ The page you were looking for cannot be served (4xx)
+
+
+
+
+
+
+
The page you were looking for cannot be served.
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/plugins/nginx-vhosts/templates/404-error.html b/plugins/nginx-vhosts/templates/404-error.html
new file mode 100644
index 000000000..b2e65ccda
--- /dev/null
+++ b/plugins/nginx-vhosts/templates/404-error.html
@@ -0,0 +1,33 @@
+
+
+
+ The page you were looking for doesn't exist (404)
+
+
+
+
+
+
+
The page you were looking for doesn't exist.
+
You may have mistyped the address or the page may have moved.
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/plugins/nginx-vhosts/templates/500-error.html b/plugins/nginx-vhosts/templates/500-error.html
new file mode 100644
index 000000000..617925fdc
--- /dev/null
+++ b/plugins/nginx-vhosts/templates/500-error.html
@@ -0,0 +1,32 @@
+
+
+
+ We're sorry, but something went wrong (500)
+
+
+
+
+
+
+
We're sorry, but something went wrong.
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/plugins/nginx-vhosts/templates/nginx.conf.sigil b/plugins/nginx-vhosts/templates/nginx.conf.sigil
index 84c51ae22..181f8d8c0 100644
--- a/plugins/nginx-vhosts/templates/nginx.conf.sigil
+++ b/plugins/nginx-vhosts/templates/nginx.conf.sigil
@@ -34,6 +34,24 @@ server {
proxy_set_header X-Request-Start $msec;
}
include {{ $.DOKKU_ROOT }}/{{ $.APP }}/nginx.conf.d/*.conf;
+
+ error_page 400 401 402 403 405 406 407 408 409 410 411 412 413 414 415 416 417 418 420 422 423 424 426 428 429 431 444 449 450 451 /400-error.html;
+ location /400-error.html {
+ root {{ $.DOKKU_LIB_ROOT }}/data/nginx-vhosts/dokku-errors;
+ internal;
+ }
+
+ error_page 404 /404-error.html;
+ location /404-error.html {
+ root {{ $.DOKKU_LIB_ROOT }}/data/nginx-vhosts/dokku-errors;
+ internal;
+ }
+
+ error_page 500 501 502 503 504 505 506 507 508 509 510 511 /500-error.html;
+ location /500-error.html {
+ root {{ $.DOKKU_LIB_ROOT }}/data/nginx-vhosts/dokku-errors;
+ internal;
+ }
{{ end }}
}
{{ else if eq $scheme "https"}}
@@ -73,6 +91,24 @@ server {
proxy_set_header X-Request-Start $msec;
}
include {{ $.DOKKU_ROOT }}/{{ $.APP }}/nginx.conf.d/*.conf;
+
+ error_page 400 401 402 403 405 406 407 408 409 410 411 412 413 414 415 416 417 418 420 422 423 424 426 428 429 431 444 449 450 451 /400-error.html;
+ location /400-error.html {
+ root {{ $.DOKKU_LIB_ROOT }}/data/nginx-vhosts/dokku-errors;
+ internal;
+ }
+
+ error_page 404 /404-error.html;
+ location /404-error.html {
+ root {{ $.DOKKU_LIB_ROOT }}/data/nginx-vhosts/dokku-errors;
+ internal;
+ }
+
+ error_page 500 501 502 503 504 505 506 507 508 509 510 511 /500-error.html;
+ location /500-error.html {
+ root {{ $.DOKKU_LIB_ROOT }}/data/nginx-vhosts/dokku-errors;
+ internal;
+ }
}
{{ end }}{{ end }}