feat: customizable error page

This commit is contained in:
Nicolas Duchon 2024-05-02 17:03:39 +02:00
parent b4c7ea603e
commit e6381d8715
No known key found for this signature in database
GPG key ID: EA3151C66A4D79E7
4 changed files with 50 additions and 1 deletions

View file

@ -702,7 +702,17 @@ 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 }}

View 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>

View 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)

View 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