From 948ec19b0e4e95674c1c75ec0d4692af000a719d Mon Sep 17 00:00:00 2001 From: perror <23651751+perrornet@users.noreply.github.com> Date: Mon, 15 Dec 2025 15:38:23 +0800 Subject: [PATCH 1/2] Add custom Nginx configuration to Dockerfile --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 13ea9c1..24f4387 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,8 @@ RUN npm run build FROM nginx:stable-alpine COPY --from=builder /app/build /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +CMD ["nginx", "-g", "daemon off;"] From 046e828cfc01b0c66b0aecadd5ac1614f46bad85 Mon Sep 17 00:00:00 2001 From: perror <23651751+perrornet@users.noreply.github.com> Date: Mon, 15 Dec 2025 15:38:56 +0800 Subject: [PATCH 2/2] Add basic Nginx configuration with caching and security --- nginx.conf | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 nginx.conf diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..d4b9f73 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,22 @@ +server { + listen 80; + server_name _; + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } + + # 静态资源缓存 + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + + # 安全 headers + add_header X-Content-Type-Options "nosniff" always; + add_header X-Frame-Options "SAMEORIGIN" always; + add_header Referrer-Policy "origin-when-cross-origin" always; + add_header Strict-Transport-Security "max-age=2592000" always; +}