From 6b22ae4112f5b7afe760e809b5e9d1b5383f3706 Mon Sep 17 00:00:00 2001 From: Felix Schmenger Date: Thu, 21 May 2026 13:28:39 +0200 Subject: [PATCH 1/3] Added default.conf from Nginx docker image for upcoming customization. --- Dockerfile | 1 + nginx/default.conf | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 nginx/default.conf diff --git a/Dockerfile b/Dockerfile index 1978d3d2..25caca33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,7 @@ RUN npm run init:app && npm run build FROM nginx:stable-alpine AS production-stage LABEL maintainer="Just van den Broecke " COPY --from=build-stage /app/dist /usr/share/nginx/html +COPY nginx/default.conf /etc/nginx/conf.d/default.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] diff --git a/nginx/default.conf b/nginx/default.conf new file mode 100644 index 00000000..ac54d8e8 --- /dev/null +++ b/nginx/default.conf @@ -0,0 +1,45 @@ +server { + listen 80; + listen [::]:80; + server_name localhost; + + #access_log /var/log/nginx/host.access.log main; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} +} + From 551fbcd4e58955357638b63e9843e5675dc8ce0e Mon Sep 17 00:00:00 2001 From: Felix Schmenger Date: Thu, 21 May 2026 13:29:23 +0200 Subject: [PATCH 2/3] Added cache-control headers to Nginx configuration. --- nginx/default.conf | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/nginx/default.conf b/nginx/default.conf index ac54d8e8..9e071761 100644 --- a/nginx/default.conf +++ b/nginx/default.conf @@ -5,6 +5,33 @@ server { #access_log /var/log/nginx/host.access.log main; + # long cache for hashed build assets + location /assets/ { + root /usr/share/nginx/html; + expires 1y; + add_header Cache-Control "public, immutable"; + } + + # disable caching for frequently changing static config/resources + location /static/ { + root /usr/share/nginx/html; + expires -1; + add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate"; + } + + # disable caching for SPA entry points + location = /index.html { + root /usr/share/nginx/html; + expires -1; + add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate"; + } + + location = /embedded.html { + root /usr/share/nginx/html; + expires -1; + add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate"; + } + location / { root /usr/share/nginx/html; index index.html index.htm; From 14ec705fdb7c91255a56977dd7e422999bfde697 Mon Sep 17 00:00:00 2001 From: Felix Schmenger Date: Thu, 21 May 2026 13:30:06 +0200 Subject: [PATCH 3/3] Added fallback to index.html to Nginx configuration. --- nginx/default.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nginx/default.conf b/nginx/default.conf index 9e071761..c7bc2404 100644 --- a/nginx/default.conf +++ b/nginx/default.conf @@ -35,6 +35,9 @@ server { location / { root /usr/share/nginx/html; index index.html index.htm; + + # SPA fallback + try_files $uri $uri/ /index.html; } #error_page 404 /404.html;