feat: customizable error page
This commit is contained in:
parent
b4c7ea603e
commit
e6381d8715
4 changed files with 50 additions and 1 deletions
10
nginx.tmpl
10
nginx.tmpl
|
@ -702,8 +702,18 @@ server {
|
|||
return 444;
|
||||
}
|
||||
{{- end }}
|
||||
|
||||
{{- if (exists "/usr/share/nginx/html/50x.html") }}
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
internal;
|
||||
}
|
||||
{{- end }}
|
||||
location / {
|
||||
return 503;
|
||||
}
|
||||
}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
|
23
test/test_custom-error-page/50x.html
Normal file
23
test/test_custom-error-page/50x.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Maintenance</title>
|
||||
<style>
|
||||
html {
|
||||
color-scheme: light dark;
|
||||
}
|
||||
body {
|
||||
width: 35em;
|
||||
margin: 0 auto;
|
||||
font-family: Tahoma, Verdana, Arial, sans-serif;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Damn, there's some maintenance in progress.</h1>
|
||||
<p>
|
||||
Our apologies for this temporary inconvenience. Regular service
|
||||
performance will be re-established shortly.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
8
test/test_custom-error-page/test_custom-error-page.py
Normal file
8
test/test_custom-error-page/test_custom-error-page.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
import pytest
|
||||
import re
|
||||
|
||||
|
||||
def test_custom_error_page(docker_compose, nginxproxy):
|
||||
r = nginxproxy.get("http://unknown.nginx-proxy.tld")
|
||||
assert r.status_code == 503
|
||||
assert re.search(r"Damn, there's some maintenance in progress.", r.text)
|
8
test/test_custom-error-page/test_custom-error-page.yml
Normal file
8
test/test_custom-error-page/test_custom-error-page.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
version: "2"
|
||||
|
||||
services:
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ./50x.html:/usr/share/nginx/html/50x.html:ro
|
Loading…
Reference in a new issue