diff --git a/nginx.tmpl b/nginx.tmpl index 2ad4339..cf4370d 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -702,7 +702,17 @@ server { return 444; } {{- end }} - return 503; + + {{- 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 }} diff --git a/test/test_custom-error-page/50x.html b/test/test_custom-error-page/50x.html new file mode 100644 index 0000000..63a299e --- /dev/null +++ b/test/test_custom-error-page/50x.html @@ -0,0 +1,23 @@ + + + + Maintenance + + + +

Damn, there's some maintenance in progress.

+

+ Our apologies for this temporary inconvenience. Regular service + performance will be re-established shortly. +

+ + diff --git a/test/test_custom-error-page/test_custom-error-page.py b/test/test_custom-error-page/test_custom-error-page.py new file mode 100644 index 0000000..32cb0b5 --- /dev/null +++ b/test/test_custom-error-page/test_custom-error-page.py @@ -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) diff --git a/test/test_custom-error-page/test_custom-error-page.yml b/test/test_custom-error-page/test_custom-error-page.yml new file mode 100644 index 0000000..8c00e0f --- /dev/null +++ b/test/test_custom-error-page/test_custom-error-page.yml @@ -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