From adbe209a9c28b6b2844317822f2d8a28f4e48861 Mon Sep 17 00:00:00 2001 From: RMCrean <49672044+RMCrean@users.noreply.github.com> Date: Wed, 11 Nov 2026 13:42:22 +0100 Subject: [PATCH] add a dedicated health check endpoint kubectl probe and uptime robot can poll there and we can ignore these access logs to stop --- Dockerfile | 4 +--- site.conf | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 site.conf diff --git a/Dockerfile b/Dockerfile index ff770d5..069b4dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,9 +14,7 @@ RUN mkdir /target && \ # Serve the generated html using nginx FROM nginxinc/nginx-unprivileged:alpine -RUN sed -i '3 a\ absolute_redirect off;' /etc/nginx/conf.d/default.conf && \ - sed -i '4 a\ add_header X-Frame-Options DENY always;' /etc/nginx/conf.d/default.conf && \ - sed -i 's/#error_page 404/error_page 404/' /etc/nginx/conf.d/default.conf +COPY site.conf /etc/nginx/conf.d/default.conf COPY --from=build /target /usr/share/nginx/html EXPOSE 8080 diff --git a/site.conf b/site.conf new file mode 100644 index 0000000..5177d0f --- /dev/null +++ b/site.conf @@ -0,0 +1,25 @@ +server { + listen 8080; + server_name localhost; + absolute_redirect off; + root /usr/share/nginx/html; + + add_header X-Frame-Options DENY always; + + location / { + index index.html index.htm; + } + + error_page 404 /404.html; + error_page 500 502 503 504 /50x.html; + location = /50x.html { + } + + # Health check endpoint for k8s probes and external uptime monitors to use (e.g. UptimeRobot). + # access log off to keep frequent health checks from cluttering the logs. + location = /healthz { + access_log off; + default_type text/plain; + return 200 'ok'; + } +}