From 26f25f88abe08d53711dc2b1a6b61a918576ae89 Mon Sep 17 00:00:00 2001 From: Muse Mulatu Date: Wed, 18 Sep 2024 17:56:49 -0600 Subject: [PATCH] fix: serve files from /usr/share/nginx/docs --- Dockerfile | 2 +- default.conf | 32 ++++++++++++++------------------ 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index b5da14d1..05e50ca7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ RUN npm install \ FROM nginx:1.25.1-alpine AS runner -WORKDIR /usr/share/nginx/html +WORKDIR /usr/share/nginx/docs ENV NODE_ENV production diff --git a/default.conf b/default.conf index 59c77323..230843b9 100644 --- a/default.conf +++ b/default.conf @@ -2,32 +2,28 @@ server { listen 80; server_name localhost; - # redirect /google/ to /gcp/ for any subpath - location /google/ { - rewrite ^/google/(.*)/$ /gcp/$1/ last; - rewrite ^/google/(.*)$ /gcp/$1 last; - } + location /docs { + root /usr/share/nginx/; - # redirect /digitalocean/ to /do/ for any subpath - location /digitalocean/ { - rewrite ^/digitalocean/(.*)/$ /do/$1/ last; - rewrite ^/digitalocean/(.*)$ /do/$1 last; - } + # redirect /docs/google/ to /docs/gcp/ for any subpath + rewrite ^/docs/google/(.*)/$ $scheme://$http_host/docs/gcp/$1/ last; + rewrite ^/docs/google/(.*)$ $scheme://$http_host/docs/gcp/$1 last; - location ~ ^/[^/]+/$ { - try_files $uri /index.html; - autoindex off; - } + # redirect /docs/digitalocean/ to /docs/do/ for any subpath + rewrite ^/docs/digitalocean/(.*)/$ $scheme://$http_host/docs/do/$1/ last; + rewrite ^/docs/digitalocean/(.*)$ $scheme://$http_host/docs/do/$1 last; - location / { - root /usr/share/nginx/html; index index.html index.htm; - try_files $uri $uri/ /index.html; + # try_files $uri $uri/ /index.html; autoindex off; } + error_page 404 = /404.html; + location /404.html { + root /usr/share/nginx/docs; + } error_page 500 502 503 504 /50x.html; location = /50x.html { - root /usr/share/nginx/html; + root /usr/share/nginx/docs; } }