From ebb40b2884ffcc7be5d50d0fb046aabe44ae509d Mon Sep 17 00:00:00 2001 From: ywp Date: Wed, 22 Oct 2025 15:09:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20nginx.conf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nginx.conf | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/nginx.conf b/nginx.conf index 5abfee7..e20af04 100644 --- a/nginx.conf +++ b/nginx.conf @@ -9,19 +9,25 @@ http { keepalive_timeout 65; upstream node_app { - server 127.0.0.1:3001; + server 127.0.0.1:3001; # Node.js 后端端口 } server { listen 80; server_name _; + # 静态文件 location / { - root /usr/share/nginx/html; + root /usr/share/nginx/html; try_files $uri /index.html; } - location /api { + location /public/ { + root /usr/share/nginx/html; + } + + # 后端 API + location /api/ { proxy_pass http://node_app; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; @@ -29,4 +35,5 @@ http { proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } - } \ No newline at end of file + } +}