fix(dockerfile): support SPA refresh to resolve nginx return 404 (#384)

* feat(dockerfile): support SPA refresh to resolve nginx return 404

* remove comments & set server_name to default

---------

Co-authored-by: Guy Ben-Aharon <guybenah@gmail.com>
This commit is contained in:
Nic
2024-11-15 02:00:14 +08:00
committed by GitHub
parent fe8b9f9e91
commit eaf75cedb0
2 changed files with 16 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ RUN npm run build
FROM nginx:stable-alpine AS production
COPY --from=builder /usr/src/app/dist /usr/share/nginx/html
COPY ./default.conf /etc/nginx/conf.d/default.conf
# Expose the default port for the Nginx web server
EXPOSE 80

15
default.conf Normal file
View File

@@ -0,0 +1,15 @@
server {
listen 80;
listen [::]:80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}