更新 nginx.conf

This commit is contained in:
ywp
2025-10-22 15:09:02 +08:00
parent 55ac4f899b
commit ebb40b2884

View File

@ -9,19 +9,25 @@ http {
keepalive_timeout 65; keepalive_timeout 65;
upstream node_app { upstream node_app {
server 127.0.0.1:3001; server 127.0.0.1:3001; # Node.js 后端端口
} }
server { server {
listen 80; listen 80;
server_name _; server_name _;
# 静态文件
location / { location / {
root /usr/share/nginx/html; root /usr/share/nginx/html;
try_files $uri /index.html; try_files $uri /index.html;
} }
location /api { location /public/ {
root /usr/share/nginx/html;
}
# 后端 API
location /api/ {
proxy_pass http://node_app; proxy_pass http://node_app;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
@ -30,3 +36,4 @@ http {
proxy_cache_bypass $http_upgrade; proxy_cache_bypass $http_upgrade;
} }
} }
}