Time_Effectiveness/nginx.conf

40 lines
880 B
Nginx Configuration File
Raw Normal View History

2025-10-22 14:55:09 +08:00
worker_processes auto;
events { worker_connections 1024; }
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream node_app {
2025-10-22 15:09:02 +08:00
server 127.0.0.1:3001; # Node.js 后端端口
2025-10-22 14:55:09 +08:00
}
server {
listen 80;
server_name _;
2025-10-22 15:09:02 +08:00
# 静态文件
2025-10-22 14:55:09 +08:00
location / {
2025-10-22 15:09:02 +08:00
root /usr/share/nginx/html;
2025-10-22 14:55:09 +08:00
try_files $uri /index.html;
}
2025-10-22 15:09:02 +08:00
location /public/ {
root /usr/share/nginx/html;
}
# 后端 API
location /api/ {
2025-10-22 14:55:09 +08:00
proxy_pass http://node_app;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
2025-10-22 15:09:02 +08:00
}
}