From 2eca029b400e069447de3af478d11b42bb8707ba Mon Sep 17 00:00:00 2001 From: James Walker Date: Fri, 6 Jan 2023 18:41:48 +0000 Subject: [PATCH 1/2] Added custom 404 error page to app-demo nginx conf with server details removed --- apps/demo/404.html | 12 ++++++++++++ build/app-demo/Dockerfile | 2 ++ 2 files changed, 14 insertions(+) create mode 100644 apps/demo/404.html diff --git a/apps/demo/404.html b/apps/demo/404.html new file mode 100644 index 0000000..570240d --- /dev/null +++ b/apps/demo/404.html @@ -0,0 +1,12 @@ + +404 Not Found + +

404 Not Found

+ + + + + + + + \ No newline at end of file diff --git a/build/app-demo/Dockerfile b/build/app-demo/Dockerfile index 10be8c4..caf122d 100644 --- a/build/app-demo/Dockerfile +++ b/build/app-demo/Dockerfile @@ -14,11 +14,13 @@ RUN rm -rf ./* # Copy assets over so Nginx can properly serve COPY apps/demo/index.html . +COPY apps/demo/404.html . RUN chown -R nginx:nginx /usr/share/nginx/html # implement changes required to run NGINX as an unprivileged user RUN sed -i 's,listen 80;,listen 8080;,' /etc/nginx/conf.d/default.conf \ + && sed -i 's,#error_page 404,error_page 404,' /etc/nginx/conf.d/default.conf \ && sed -i '/user nginx;/d' /etc/nginx/nginx.conf \ && sed -i 's,/var/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \ && sed -i "/^http {/a \ proxy_temp_path /tmp/proxy_temp;\n client_body_temp_path /tmp/client_temp;\n fastcgi_temp_path /tmp/fastcgi_temp;\n uwsgi_temp_path /tmp/uwsgi_temp;\n scgi_temp_path /tmp/scgi_temp;\n" /etc/nginx/nginx.conf \ From 7ee97a0f93a05558f09b02f0637ac7f91de98cfe Mon Sep 17 00:00:00 2001 From: James Walker Date: Fri, 6 Jan 2023 19:11:32 +0000 Subject: [PATCH 2/2] Removed nginx version from Server response header --- build/app-demo/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/app-demo/Dockerfile b/build/app-demo/Dockerfile index caf122d..4ddd73d 100644 --- a/build/app-demo/Dockerfile +++ b/build/app-demo/Dockerfile @@ -23,7 +23,7 @@ RUN sed -i 's,listen 80;,listen 8080;,' /etc/nginx/conf.d/default.co && sed -i 's,#error_page 404,error_page 404,' /etc/nginx/conf.d/default.conf \ && sed -i '/user nginx;/d' /etc/nginx/nginx.conf \ && sed -i 's,/var/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \ - && sed -i "/^http {/a \ proxy_temp_path /tmp/proxy_temp;\n client_body_temp_path /tmp/client_temp;\n fastcgi_temp_path /tmp/fastcgi_temp;\n uwsgi_temp_path /tmp/uwsgi_temp;\n scgi_temp_path /tmp/scgi_temp;\n" /etc/nginx/nginx.conf \ + && sed -i "/^http {/a \ proxy_temp_path /tmp/proxy_temp;\n client_body_temp_path /tmp/client_temp;\n fastcgi_temp_path /tmp/fastcgi_temp;\n uwsgi_temp_path /tmp/uwsgi_temp;\n scgi_temp_path /tmp/scgi_temp;\n server_tokens off;\n" /etc/nginx/nginx.conf \ # nginx user must own the cache and etc directory to write cache and tweak the nginx config && chown -R $UID:0 /var/cache/nginx \ && chmod -R g+w /var/cache/nginx \