From 334752373ec4e0813e1210732ebb962b3451ff77 Mon Sep 17 00:00:00 2001 From: mayiming <1627832236@qq.com> Date: Tue, 4 Nov 2025 17:45:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=BC=96=E5=86=99=E8=AE=BF?= =?UTF-8?q?=E9=97=AE=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- management/nginx.conf | 24 ++++++++++++++++++++++++ web/nginx.conf | 24 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 management/nginx.conf create mode 100644 web/nginx.conf diff --git a/management/nginx.conf b/management/nginx.conf new file mode 100644 index 00000000..654c7334 --- /dev/null +++ b/management/nginx.conf @@ -0,0 +1,24 @@ +server { + listen 80; + server_name localhost; + + # 站点根目录(与Dockerfile中复制的目录一致) + root /usr/share/nginx/html; + index index.html; + + # 解决SPA路由刷新404问题:所有请求转发到index.html + location / { + try_files $uri $uri/ /index.html; + } + + # 禁止访问隐藏文件(如.gitignore等) + location ~ /\. { + deny all; + } + + # 静态资源缓存配置(可选,优化性能) + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { + expires 1d; + add_header Cache-Control "public, max-age=86400"; + } +} \ No newline at end of file diff --git a/web/nginx.conf b/web/nginx.conf new file mode 100644 index 00000000..654c7334 --- /dev/null +++ b/web/nginx.conf @@ -0,0 +1,24 @@ +server { + listen 80; + server_name localhost; + + # 站点根目录(与Dockerfile中复制的目录一致) + root /usr/share/nginx/html; + index index.html; + + # 解决SPA路由刷新404问题:所有请求转发到index.html + location / { + try_files $uri $uri/ /index.html; + } + + # 禁止访问隐藏文件(如.gitignore等) + location ~ /\. { + deny all; + } + + # 静态资源缓存配置(可选,优化性能) + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { + expires 1d; + add_header Cache-Control "public, max-age=86400"; + } +} \ No newline at end of file