From 539c9c745302d8d896d7beadc449df9c073d0807 Mon Sep 17 00:00:00 2001 From: carry <2641257231@qq.com> Date: Thu, 20 Feb 2025 01:19:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BA=86nginx=E9=95=9C?= =?UTF-8?q?=E5=83=8F=E7=9A=84spa=E8=B7=AF=E7=94=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 3 +++ nginx.conf | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile index 263d0b6..d5d255b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,6 +23,9 @@ FROM nginx:stable-alpine as production-stage # 复制构建好的文件到Nginx目录 COPY --from=build-stage /app/dist /usr/share/nginx/html +# 复制Nginx配置文件 +COPY nginx.conf /etc/nginx/conf.d/default.conf + # 暴露80端口 EXPOSE 80 diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..7a46994 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,21 @@ +# 用户连接数 +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + server { + listen 80; + + # 设置根目录 + root /usr/share/nginx/html; + index index.html; + + # 处理SPA路由 + location / { + try_files $uri $uri/ /index.html; + } + } +} \ No newline at end of file From 20283e17b94864887dd5d9bda506a19ab0f12b70 Mon Sep 17 00:00:00 2001 From: carry <2641257231@qq.com> Date: Thu, 20 Feb 2025 02:48:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=B0=86nginx=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=AD=A3=E7=A1=AE=E6=94=BE=E5=85=A5=E5=AE=B9=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d5d255b..6107578 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ FROM nginx:stable-alpine as production-stage COPY --from=build-stage /app/dist /usr/share/nginx/html # 复制Nginx配置文件 -COPY nginx.conf /etc/nginx/conf.d/default.conf +COPY nginx.conf /etc/nginx/nginx.conf # 暴露80端口 EXPOSE 80