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

Commit 85640f8

Browse files
TobiXdiemol
authored andcommitted
Initial implemenation of custom error pages
1 parent f499784 commit 85640f8

File tree

4 files changed

+55
-2
lines changed

4 files changed

+55
-2
lines changed

docker/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ ENV ZAL_VER="${project.build.finalName}" \
366366
SELENIUM_WAIT_FOR_CONTAINER="true"
367367

368368
COPY entry.sh log warn error /usr/bin/
369-
COPY nginx.conf /home/seluser/
369+
COPY nginx.conf error.html /home/seluser/
370370
COPY css/ /home/seluser/css/
371371
COPY js/ /home/seluser/js/
372372
COPY img/ /home/seluser/img/

docker/error.html

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Zalenium - <!--# echo var="status" default="" -->
6+
<!--# if expr="$status_text" -->
7+
- <!--# echo var="status_text" -->
8+
<!--# endif -->
9+
</title>
10+
<meta name="viewport" content="width=device-width, initial-scale=1">
11+
<style>
12+
h1 { text-align: center; }
13+
address { text-align: center; }
14+
</style>
15+
</head>
16+
<body>
17+
<h1><!--# echo var="status" -->
18+
<!--# if expr="$status_text" -->
19+
- <!--# echo var="status_text" -->
20+
<!--# endif -->
21+
</h1>
22+
<hr>
23+
<address>nginx/<!--# echo var="nginx_version" --> - Zalenium {{zaleniumVersion}}</address>
24+
</body>
25+
</html>

docker/nginx.conf

+28-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,26 @@ http {
1010
proxy_read_timeout 900s;
1111
send_timeout 900s;
1212

13+
map $status $status_text {
14+
400 'Bad Request';
15+
401 'Unauthorized';
16+
403 'Forbidden';
17+
404 'Not Found';
18+
405 'Method Not Allowed';
19+
406 'Not Acceptable';
20+
413 'Payload Too Large';
21+
414 'URI Too Long';
22+
431 'Request Header Fields Too Large';
23+
500 'Internal Server Error';
24+
501 'Not Implemented';
25+
502 'Bad Gateway';
26+
503 'Service Unavailable';
27+
504 'Gateway Timeout';
28+
}
29+
1330
server {
1431
listen 4444;
15-
32+
1633
satisfy any;
1734
allow 127.0.0.1;
1835
auth_basic_user_file /home/seluser/.htpasswd;
@@ -24,6 +41,16 @@ http {
2441
}
2542
auth_basic $auth_basic;
2643

44+
error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
45+
415 416 417 418 421 422 423 424 426 428 429 431 451 500 501 502 503
46+
504 505 506 507 508 510 511 /error.html;
47+
48+
location = /error.html {
49+
ssi on;
50+
internal;
51+
alias /home/seluser/error.html;
52+
}
53+
2754
location {{contextPath}}/ {
2855
rewrite ^{{contextPath}}/(.*) /$1 break;
2956
# https://github.com/zalando/zalenium/issues/817

scripts/zalenium.sh

+1
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ StartUp()
489489
# In nginx.conf, Replace {{contextPath}} with value of APPEND_CONTEXT_PATH
490490
sed -i.bak "s~{{contextPath}}~${CONTEXT_PATH}~" /home/seluser/nginx.conf
491491
sed -i.bak "s~{{nginxMaxBodySize}}~${NGINX_MAX_BODY_SIZE}~" /home/seluser/nginx.conf
492+
sed -i.bak "s~{{zaleniumVersion}}~${project.version}~" /home/seluser/error.html
492493

493494
echo "Starting Nginx reverse proxy..."
494495
nginx -c /home/seluser/nginx.conf

0 commit comments

Comments
 (0)