From 64a9ce84d4b579b399b2c2aa6da68925c878c9f3 Mon Sep 17 00:00:00 2001 From: Neeldhara Misra Date: Sat, 13 Jun 2026 20:16:35 +0200 Subject: [PATCH] Serve multisite blogs from explicit Nginx roots --- Dockerfile | 1 + deploy/blog-locations.conf | 19 ++++++++++ deploy/nginx.conf | 76 ++++++++++++++++++++++---------------- 3 files changed, 64 insertions(+), 32 deletions(-) create mode 100644 deploy/blog-locations.conf diff --git a/Dockerfile b/Dockerfile index 05dca2b..9f70b47 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ RUN npm run build FROM nginx:1.27-alpine AS runtime COPY deploy/nginx.conf /etc/nginx/conf.d/default.conf +COPY deploy/blog-locations.conf /etc/nginx/snippets/blog-locations.conf COPY --from=build /app/dist /usr/share/nginx/html EXPOSE 80 diff --git a/deploy/blog-locations.conf b/deploy/blog-locations.conf new file mode 100644 index 0000000..e998d4e --- /dev/null +++ b/deploy/blog-locations.conf @@ -0,0 +1,19 @@ +index index.html; + +access_log /var/log/nginx/access.log; +error_log /var/log/nginx/error.log warn; + +location = /nginx-health { + access_log off; + return 204; +} + +location ~* \.(?:css|js|mjs|png|jpg|jpeg|gif|svg|webp|ico|woff2?)$ { + try_files $uri =404; + expires 1y; + add_header Cache-Control "public, immutable"; +} + +location / { + try_files $uri $uri/index.html /index.html /404.html; +} diff --git a/deploy/nginx.conf b/deploy/nginx.conf index 22d084d..fa5cd0d 100644 --- a/deploy/nginx.conf +++ b/deploy/nginx.conf @@ -1,36 +1,48 @@ -map $host $blog_site { - default research; - research.neeldhara.blog research; - vibes.neeldhara.blog vibes; - puzzles.neeldhara.blog puzzles; - reflections.neeldhara.blog reflections; - poetry.neeldhara.blog poetry; - reviews.neeldhara.blog reviews; - art.neeldhara.blog art; +server { + listen 80 default_server; + server_name research.neeldhara.blog research.neeldhara.email _; + root /usr/share/nginx/html/research; + include /etc/nginx/snippets/blog-locations.conf; } server { - listen 80 default_server; - server_name _; - - root /usr/share/nginx/html/$blog_site; - index index.html; - - access_log /var/log/nginx/access.log; - error_log /var/log/nginx/error.log warn; - - location = /nginx-health { - access_log off; - return 204; - } - - location ~* \.(?:css|js|mjs|png|jpg|jpeg|gif|svg|webp|ico|woff2?)$ { - try_files $uri =404; - expires 1y; - add_header Cache-Control "public, immutable"; - } - - location / { - try_files $uri $uri/ /404.html; - } + listen 80; + server_name vibes.neeldhara.blog vibes.neeldhara.email; + root /usr/share/nginx/html/vibes; + include /etc/nginx/snippets/blog-locations.conf; +} + +server { + listen 80; + server_name puzzles.neeldhara.blog puzzles.neeldhara.email; + root /usr/share/nginx/html/puzzles; + include /etc/nginx/snippets/blog-locations.conf; +} + +server { + listen 80; + server_name reflections.neeldhara.blog reflections.neeldhara.email; + root /usr/share/nginx/html/reflections; + include /etc/nginx/snippets/blog-locations.conf; +} + +server { + listen 80; + server_name poetry.neeldhara.blog poetry.neeldhara.email; + root /usr/share/nginx/html/poetry; + include /etc/nginx/snippets/blog-locations.conf; +} + +server { + listen 80; + server_name reviews.neeldhara.blog reviews.neeldhara.email; + root /usr/share/nginx/html/reviews; + include /etc/nginx/snippets/blog-locations.conf; +} + +server { + listen 80; + server_name art.neeldhara.blog art.neeldhara.email; + root /usr/share/nginx/html/art; + include /etc/nginx/snippets/blog-locations.conf; }