From 153a8c635d8b85e05fc09f3c2449b35d222c342e Mon Sep 17 00:00:00 2001 From: Minh141120 Date: Fri, 5 Sep 2025 17:26:22 +0700 Subject: [PATCH] chore: update Dockerfile to use custom nginx.conf --- Dockerfile | 4 ++-- nginx.conf | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile index 840ae887f..d05a1f372 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,8 +38,8 @@ FROM nginx:alpine # Copy static files from build stage COPY --from=builder /app/web-app/dist-web /usr/share/nginx/html -# Copy nginx configuration for SPA (if custom config is needed) -# COPY nginx.conf /etc/nginx/nginx.conf +# Copy custom nginx config +COPY nginx.conf /etc/nginx/conf.d/default.conf # Expose port 80 EXPOSE 80 diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 000000000..58d44f67e --- /dev/null +++ b/nginx.conf @@ -0,0 +1,22 @@ +server { + listen 80; + server_name localhost; + root /usr/share/nginx/html; + index index.html; + + # Handle routes with or without trailing slash + location / { + try_files $uri $uri/ $uri.html $uri/index.html /index.html; + } + + # Security headers + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-XSS-Protection "1; mode=block" always; + + # Cache static assets + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } +} \ No newline at end of file