挂载更新
This commit is contained in:
74
docker/nginx/conf.d/default.conf
Normal file
74
docker/nginx/conf.d/default.conf
Normal file
@@ -0,0 +1,74 @@
|
||||
# ====================================
|
||||
# 校园新闻系统 - 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;
|
||||
}
|
||||
}
|
||||
44
docker/nginx/nginx.conf
Normal file
44
docker/nginx/nginx.conf
Normal file
@@ -0,0 +1,44 @@
|
||||
# ====================================
|
||||
# Nginx主配置文件
|
||||
# 可通过docker-compose.yml挂载自定义配置
|
||||
# ====================================
|
||||
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
|
||||
error_log /var/log/nginx/error.log notice;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
# 日志格式
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
|
||||
# Gzip压缩
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_types text/plain text/css text/xml text/javascript
|
||||
application/json application/javascript application/xml+rss
|
||||
application/rss+xml font/truetype font/opentype
|
||||
application/vnd.ms-fontobject image/svg+xml;
|
||||
|
||||
# 包含站点配置
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
}
|
||||
Reference in New Issue
Block a user