Skip to content

Commit

Permalink
fix: serve files from /usr/share/nginx/docs
Browse files Browse the repository at this point in the history
  • Loading branch information
muse-sisay committed Sep 18, 2024
1 parent d1f546b commit 26f25f8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
32 changes: 14 additions & 18 deletions default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 26f25f8

Please sign in to comment.