From 85640f88929a4044ceb4d8f9fd8c3bfd17c6cd76 Mon Sep 17 00:00:00 2001 From: Tobias Gruetzmacher Date: Tue, 1 Oct 2019 00:21:40 +0200 Subject: [PATCH] Initial implemenation of custom error pages --- docker/Dockerfile | 2 +- docker/error.html | 25 +++++++++++++++++++++++++ docker/nginx.conf | 29 ++++++++++++++++++++++++++++- scripts/zalenium.sh | 1 + 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 docker/error.html diff --git a/docker/Dockerfile b/docker/Dockerfile index 69737a501d..cfe129d34d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -366,7 +366,7 @@ ENV ZAL_VER="${project.build.finalName}" \ SELENIUM_WAIT_FOR_CONTAINER="true" COPY entry.sh log warn error /usr/bin/ -COPY nginx.conf /home/seluser/ +COPY nginx.conf error.html /home/seluser/ COPY css/ /home/seluser/css/ COPY js/ /home/seluser/js/ COPY img/ /home/seluser/img/ diff --git a/docker/error.html b/docker/error.html new file mode 100644 index 0000000000..1d3f6c763b --- /dev/null +++ b/docker/error.html @@ -0,0 +1,25 @@ + + + + + Zalenium - <!--# echo var="status" default="" --> + <!--# if expr="$status_text" --> + - <!--# echo var="status_text" --> + <!--# endif --> + + + + + +

+ + - + +

+
+
nginx/ - Zalenium {{zaleniumVersion}}
+ + diff --git a/docker/nginx.conf b/docker/nginx.conf index f5ccb09816..2dd493cd95 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -10,9 +10,26 @@ http { proxy_read_timeout 900s; send_timeout 900s; + map $status $status_text { + 400 'Bad Request'; + 401 'Unauthorized'; + 403 'Forbidden'; + 404 'Not Found'; + 405 'Method Not Allowed'; + 406 'Not Acceptable'; + 413 'Payload Too Large'; + 414 'URI Too Long'; + 431 'Request Header Fields Too Large'; + 500 'Internal Server Error'; + 501 'Not Implemented'; + 502 'Bad Gateway'; + 503 'Service Unavailable'; + 504 'Gateway Timeout'; + } + server { listen 4444; - + satisfy any; allow 127.0.0.1; auth_basic_user_file /home/seluser/.htpasswd; @@ -24,6 +41,16 @@ http { } auth_basic $auth_basic; + error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 + 415 416 417 418 421 422 423 424 426 428 429 431 451 500 501 502 503 + 504 505 506 507 508 510 511 /error.html; + + location = /error.html { + ssi on; + internal; + alias /home/seluser/error.html; + } + location {{contextPath}}/ { rewrite ^{{contextPath}}/(.*) /$1 break; # https://github.com/zalando/zalenium/issues/817 diff --git a/scripts/zalenium.sh b/scripts/zalenium.sh index b13fccd30b..ec19ce0d25 100755 --- a/scripts/zalenium.sh +++ b/scripts/zalenium.sh @@ -489,6 +489,7 @@ StartUp() # In nginx.conf, Replace {{contextPath}} with value of APPEND_CONTEXT_PATH sed -i.bak "s~{{contextPath}}~${CONTEXT_PATH}~" /home/seluser/nginx.conf sed -i.bak "s~{{nginxMaxBodySize}}~${NGINX_MAX_BODY_SIZE}~" /home/seluser/nginx.conf + sed -i.bak "s~{{zaleniumVersion}}~${project.version}~" /home/seluser/error.html echo "Starting Nginx reverse proxy..." nginx -c /home/seluser/nginx.conf