Files
MHXY_Web/frontend/nginx.conf
2025-12-22 23:51:21 +08:00

44 lines
1.2 KiB
Nginx Configuration File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
server {
listen 80;
server_name localhost;
# 配置静态资源服务
location / {
root /usr/share/nginx/html;
index index.html;
# 处理前端路由SPA模式
try_files $uri $uri/ /index.html;
}
# 配置API反向代理到后端服务
location /api/ {
proxy_pass http://backend:3000/api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# 增加超时配置
proxy_connect_timeout 5s;
proxy_read_timeout 60s;
proxy_send_timeout 60s;
}
# 配置游戏API代理如果需要
location /game-api/ {
proxy_pass http://backend:3000/game-api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# 增加超时配置
proxy_connect_timeout 5s;
proxy_read_timeout 60s;
proxy_send_timeout 60s;
}
# 配置404页面
error_page 404 /index.html;
}