diff --git a/Dockerfile b/Dockerfile index 8bf9390..d435d79 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,7 +47,7 @@ RUN rm -rf /etc/nginx/conf.d/default.conf COPY docker/nginx.conf /etc/nginx/conf.d/default.conf # 从构建阶段复制构建产物(UniApp H5 输出目录) -COPY --from=builder /build/dist/build/h5 /usr/share/nginx/html +COPY --from=builder /build/dist/build/h5 /usr/share/nginx/html/h5 # 暴露端口 EXPOSE 80 diff --git a/docker/nginx.conf b/docker/nginx.conf index 94468c2..8445fc3 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -17,10 +17,14 @@ server { add_header Content-Type text/plain; } - location / { + location /h5/ { try_files $uri $uri/ /index.html; } + location = / { + return 301 /h5/; + } + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { expires 1y; add_header Cache-Control "public, immutable";