diff --git a/Dockerfile b/Dockerfile index 598d109..4c25170 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,8 +39,8 @@ RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories # 复制构建结果到Nginx目录 COPY --from=build-stage /app/dist /usr/share/nginx/html -# 复制自定义Nginx配置(可选) -# COPY nginx.conf /etc/nginx/conf.d/default.conf +# 复制Nginx配置文件 +COPY nginx.conf /etc/nginx/conf.d/default.conf # 暴露80端口 EXPOSE 80 diff --git a/nginx.conf b/nginx.conf index f145b4f..cae77b2 100644 --- a/nginx.conf +++ b/nginx.conf @@ -9,12 +9,6 @@ server { gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml; gzip_vary on; - # 资源文件缓存 - location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { - root /usr/share/nginx/html; - expires 1d; - } - location / { root /usr/share/nginx/html; index index.html index.htm; @@ -22,6 +16,12 @@ server { try_files $uri $uri/ /index.html; } + # 缓存静态资源 + location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { + root /usr/share/nginx/html; + expires 1d; + } + # 错误页面 error_page 500 502 503 504 /50x.html; location = /50x.html {