Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
Initial implemenation of custom error pages
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiX authored and diemol committed Oct 13, 2019
1 parent f499784 commit 85640f8
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
25 changes: 25 additions & 0 deletions docker/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Zalenium - <!--# echo var="status" default="" -->
<!--# if expr="$status_text" -->
- <!--# echo var="status_text" -->
<!--# endif -->
</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
h1 { text-align: center; }
address { text-align: center; }
</style>
</head>
<body>
<h1><!--# echo var="status" -->
<!--# if expr="$status_text" -->
- <!--# echo var="status_text" -->
<!--# endif -->
</h1>
<hr>
<address>nginx/<!--# echo var="nginx_version" --> - Zalenium {{zaleniumVersion}}</address>
</body>
</html>
29 changes: 28 additions & 1 deletion docker/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions scripts/zalenium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 85640f8

Please sign in to comment.