修正nginx的mime问题

main
mula.liu 2026-02-03 15:46:37 +08:00
parent 2a96afa4ab
commit 1c9a8da29e
2 changed files with 44 additions and 0 deletions

View File

@ -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

41
nginx.conf 100644
View File

@ -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;
}
}
}