From 1c9a8da29e53eae9ff77e8c8d4082589ef55e24d Mon Sep 17 00:00:00 2001 From: "mula.liu" Date: Tue, 3 Feb 2026 15:46:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3nginx=E7=9A=84mime=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 3 +++ nginx.conf | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile index 5e56c84..ff86604 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,9 @@ RUN pnpm build # Stage 2: Serve with Nginx FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nginx:alpine +# Copy custom Nginx configuration +COPY nginx.conf /etc/nginx/nginx.conf + # Copy built assets from builder stage COPY --from=builder /app/dist /usr/share/nginx/html diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..4392d4a --- /dev/null +++ b/nginx.conf @@ -0,0 +1,41 @@ +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + # Explicitly add support for .mjs files + types { + application/javascript mjs; + } + + sendfile on; + keepalive_timeout 65; + + server { + listen 80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + # Cache control for static assets + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|mjs)$ { + root /usr/share/nginx/html; + expires 1y; + add_header Cache-Control "public, no-transform"; + } + + # Error pages + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + } +}