169 lines
4.6 KiB
Plaintext
169 lines
4.6 KiB
Plaintext
# Nginx本地开发环境多客户端配置
|
|
# 基于api-config.ts中的开发环境配置
|
|
# 用于本地测试多客户端反向代理功能
|
|
|
|
# 上游服务器配置 - 指向本地开发服务器
|
|
upstream docreview_local {
|
|
server 127.0.0.1:5173; # Vite开发服务器
|
|
keepalive 32;
|
|
}
|
|
|
|
# 客户端A - 端口8001 (本地测试)
|
|
server {
|
|
listen 8001;
|
|
server_name localhost 127.0.0.1;
|
|
|
|
# 访问日志
|
|
access_log logs/local-client-a-access.log;
|
|
error_log logs/local-client-a-error.log;
|
|
|
|
# 客户端标识
|
|
set $client_id "client-a";
|
|
|
|
location / {
|
|
# 反向代理到本地开发服务器
|
|
proxy_pass http://docreview_local;
|
|
|
|
# 设置代理头部
|
|
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_set_header X-Client-ID $client_id;
|
|
|
|
# 开发环境特殊配置
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
# 连接设置
|
|
proxy_connect_timeout 30s;
|
|
proxy_send_timeout 30s;
|
|
proxy_read_timeout 30s;
|
|
|
|
# 禁用缓冲以支持热重载
|
|
proxy_buffering off;
|
|
proxy_cache off;
|
|
|
|
# 支持WebSocket (Vite HMR)
|
|
proxy_http_version 1.1;
|
|
}
|
|
|
|
# 健康检查
|
|
location /health {
|
|
access_log off;
|
|
return 200 "Local Client A - OK";
|
|
add_header Content-Type text/plain;
|
|
}
|
|
}
|
|
|
|
# 客户端B - 端口8002 (本地测试)
|
|
server {
|
|
listen 8002;
|
|
server_name localhost 127.0.0.1;
|
|
|
|
# 访问日志
|
|
access_log logs/local-client-b-access.log;
|
|
error_log logs/local-client-b-error.log;
|
|
|
|
# 客户端标识
|
|
set $client_id "client-b";
|
|
|
|
location / {
|
|
# 反向代理到本地开发服务器
|
|
proxy_pass http://docreview_local;
|
|
|
|
# 设置代理头部
|
|
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_set_header X-Client-ID $client_id;
|
|
|
|
# 开发环境特殊配置
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
# 连接设置
|
|
proxy_connect_timeout 30s;
|
|
proxy_send_timeout 30s;
|
|
proxy_read_timeout 30s;
|
|
|
|
# 禁用缓冲以支持热重载
|
|
proxy_buffering off;
|
|
proxy_cache off;
|
|
|
|
# 支持WebSocket (Vite HMR)
|
|
proxy_http_version 1.1;
|
|
}
|
|
|
|
# 健康检查
|
|
location /health {
|
|
access_log off;
|
|
return 200 "Local Client B - OK";
|
|
add_header Content-Type text/plain;
|
|
}
|
|
}
|
|
|
|
# 客户端C - 端口8003 (本地测试)
|
|
server {
|
|
listen 8003;
|
|
server_name localhost 127.0.0.1;
|
|
|
|
# 访问日志
|
|
access_log logs/local-client-c-access.log;
|
|
error_log logs/local-client-c-error.log;
|
|
|
|
# 客户端标识
|
|
set $client_id "client-c";
|
|
|
|
location / {
|
|
# 反向代理到本地开发服务器
|
|
proxy_pass http://docreview_local;
|
|
|
|
# 设置代理头部
|
|
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_set_header X-Client-ID $client_id;
|
|
|
|
# 开发环境特殊配置
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
# 连接设置
|
|
proxy_connect_timeout 30s;
|
|
proxy_send_timeout 30s;
|
|
proxy_read_timeout 30s;
|
|
|
|
# 禁用缓冲以支持热重载
|
|
proxy_buffering off;
|
|
proxy_cache off;
|
|
|
|
# 支持WebSocket (Vite HMR)
|
|
proxy_http_version 1.1;
|
|
}
|
|
|
|
# 健康检查
|
|
location /health {
|
|
access_log off;
|
|
return 200 "Local Client C - OK";
|
|
add_header Content-Type text/plain;
|
|
}
|
|
}
|
|
|
|
# 全局配置
|
|
# 错误页面
|
|
error_page 502 503 504 /50x.html;
|
|
location = /50x.html {
|
|
root html;
|
|
}
|
|
|
|
# 开发环境安全头部(相对宽松)
|
|
add_header X-Frame-Options SAMEORIGIN;
|
|
add_header X-Content-Type-Options nosniff;
|
|
|
|
# 开发环境CORS支持
|
|
add_header Access-Control-Allow-Origin *;
|
|
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS";
|
|
add_header Access-Control-Allow-Headers "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,X-Client-ID"; |