Files
schoolNews/docker/schoolNews/nginx/conf.d/default.conf
2025-11-26 16:03:06 +08:00

75 lines
2.0 KiB
Plaintext
Raw 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.

# ====================================
# 校园新闻系统 - Nginx反向代理配置
# ====================================
# 上游服务定义
upstream web_backend {
server school-news-web:4173;
}
upstream api_backend {
server school-news-serv:8081;
}
server {
listen 80;
server_name localhost;
# 日志配置
access_log /var/log/nginx/school-news-access.log;
error_log /var/log/nginx/school-news-error.log;
# 客户端上传大小限制
client_max_body_size 100M;
# 根路径重定向到前端
location = / {
return 301 /schoolNewsWeb/;
}
# 前端应用代理Node Vite Preview
location /schoolNewsWeb/ {
proxy_pass http://web_backend/;
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;
# WebSocket支持如果需要HMR
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# 超时设置
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
# 后端API代理
location /schoolNewsServ/ {
proxy_pass http://api_backend/schoolNewsServ/;
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 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
# 缓冲设置
proxy_buffering on;
proxy_buffer_size 4k;
proxy_buffers 8 4k;
}
# 错误页面
error_page 404 /schoolNewsWeb/;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}