From 75e4c0dee6bee65438d91868ea0678a8a4abe634 Mon Sep 17 00:00:00 2001 From: Nicolas Duchon Date: Tue, 21 May 2024 13:23:45 +0200 Subject: [PATCH] fix: don't use default nginx image error page --- Dockerfile.alpine | 3 ++- Dockerfile.debian | 3 ++- docs/README.md | 4 ++-- nginx.tmpl | 4 ++-- test/test_custom-error-page/test_custom-error-page.yml | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 3137a17..c8ca701 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -22,7 +22,8 @@ RUN echo -e "\ninclude /etc/nginx/toplevel.conf.d/*.conf;" >> /etc/nginx/nginx.c && sed -i -e '/^\}$/{s//\}\nworker_rlimit_nofile 20480;/;:a' -e '$!N;$!ba' -e '}' /etc/nginx/nginx.conf \ && mkdir -p '/etc/nginx/toplevel.conf.d' \ && mkdir -p '/etc/nginx/dhparam' \ - && mkdir -p '/etc/nginx/certs' + && mkdir -p '/etc/nginx/certs' \ + && mkdir -p '/usr/share/nginx/html/errors' # Install Forego + docker-gen COPY --from=forego /usr/local/bin/forego /usr/local/bin/forego diff --git a/Dockerfile.debian b/Dockerfile.debian index cc9545b..08c014e 100644 --- a/Dockerfile.debian +++ b/Dockerfile.debian @@ -19,7 +19,8 @@ RUN echo "\ninclude /etc/nginx/toplevel.conf.d/*.conf;" >> /etc/nginx/nginx.conf && sed -i -e '/^\}$/{s//\}\nworker_rlimit_nofile 20480;/;:a' -e '$!N;$!ba' -e '}' /etc/nginx/nginx.conf \ && mkdir -p '/etc/nginx/toplevel.conf.d' \ && mkdir -p '/etc/nginx/dhparam' \ - && mkdir -p '/etc/nginx/certs' + && mkdir -p '/etc/nginx/certs' \ + && mkdir -p '/usr/share/nginx/html/errors' # Install Forego + docker-gen COPY --from=forego /usr/local/bin/forego /usr/local/bin/forego diff --git a/docs/README.md b/docs/README.md index 03201a0..511678c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -799,14 +799,14 @@ Per virtual-host `servers_tokens` directive can be configured by passing appropr ### Custom error page -To override the default (nginx provided) error page displayed on 50x errors, mount your custom HTML error page inside the container at `/usr/share/nginx/html/50x.html`: +To override the default (nginx provided) error page displayed on 50x errors, mount your custom HTML error page inside the container at `/usr/share/nginx/html/errors/50x.html`: ```console docker run --detach \ --name nginx-proxy \ --publish 80:80 \ --volume /var/run/docker.sock:/tmp/docker.sock:ro \ - --volume /path/to/error.html:/usr/share/nginx/html/50x.html:ro \ + --volume /path/to/error.html:/usr/share/nginx/html/errors/50x.html:ro \ nginxproxy/nginx-proxy:1.5 ``` diff --git a/nginx.tmpl b/nginx.tmpl index f97f607..86f001f 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -703,10 +703,10 @@ server { } {{- end }} - {{- if (exists "/usr/share/nginx/html/50x.html") }} + {{- if (exists "/usr/share/nginx/html/errors/50x.html") }} error_page 500 502 503 504 /50x.html; location /50x.html { - root /usr/share/nginx/html; + root /usr/share/nginx/html/errors; internal; } {{- end }} diff --git a/test/test_custom-error-page/test_custom-error-page.yml b/test/test_custom-error-page/test_custom-error-page.yml index 8c00e0f..419b7eb 100644 --- a/test/test_custom-error-page/test_custom-error-page.yml +++ b/test/test_custom-error-page/test_custom-error-page.yml @@ -5,4 +5,4 @@ services: image: nginxproxy/nginx-proxy:test volumes: - /var/run/docker.sock:/tmp/docker.sock:ro - - ./50x.html:/usr/share/nginx/html/50x.html:ro + - ./50x.html:/usr/share/nginx/html/errors/50x.html:ro