142 lines
4.5 KiB
Nginx Configuration File
142 lines
4.5 KiB
Nginx Configuration File
worker_processes 1;
|
||
|
||
events {
|
||
worker_connections 1024;
|
||
}
|
||
|
||
http {
|
||
include mime.types;
|
||
default_type application/octet-stream;
|
||
|
||
sendfile on;
|
||
keepalive_timeout 65;
|
||
|
||
# 日志配置
|
||
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 logs/access.log main;
|
||
error_log logs/error.log;
|
||
|
||
# HTTP 自动跳 HTTPS
|
||
server {
|
||
listen 80;
|
||
server_name pactgo.cn;
|
||
return 301 https://$host$request_uri;
|
||
}
|
||
|
||
# HTTPS 服务器 - 网关服务
|
||
server {
|
||
listen 443 ssl;
|
||
server_name pactgo.cn;
|
||
|
||
# SSL证书配置
|
||
ssl_certificate C:/nginx/ssl/pactgo.cn-chain.pem;
|
||
ssl_certificate_key C:/nginx/ssl/pactgo.cn-key.pem;
|
||
|
||
ssl_session_cache shared:SSL:1m;
|
||
ssl_session_timeout 5m;
|
||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||
ssl_prefer_server_ciphers on;
|
||
|
||
# 企业微信回调 - 网关服务API
|
||
location /wecom {
|
||
proxy_pass http://127.0.0.1:8000/api/v1/wechat/callback;
|
||
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_read_timeout 30s;
|
||
proxy_connect_timeout 10s;
|
||
}
|
||
|
||
# 微信小程序回调 - 网关服务API
|
||
location /api/v1/wechat/miniprogram/callback {
|
||
proxy_pass http://127.0.0.1:8000;
|
||
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;
|
||
}
|
||
|
||
# 网关服务其他API
|
||
location /api/ {
|
||
proxy_pass http://127.0.0.1:8000;
|
||
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;
|
||
|
||
# API超时设置
|
||
proxy_read_timeout 60s;
|
||
proxy_connect_timeout 10s;
|
||
}
|
||
|
||
# WebSocket控制通道 - SmartClaw服务连接
|
||
location /ws/control {
|
||
proxy_pass http://127.0.0.1:8000;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Upgrade $http_upgrade;
|
||
proxy_set_header Connection "upgrade";
|
||
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特殊超时设置
|
||
proxy_read_timeout 86400s; # 24小时,支持长连接
|
||
proxy_connect_timeout 10s;
|
||
|
||
# 禁用缓存
|
||
proxy_cache off;
|
||
}
|
||
|
||
# WebSocket任务通道
|
||
location /ws/task {
|
||
proxy_pass http://127.0.0.1:8000;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Upgrade $http_upgrade;
|
||
proxy_set_header Connection "upgrade";
|
||
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特殊超时设置
|
||
proxy_read_timeout 86400s; # 24小时,支持长连接
|
||
proxy_connect_timeout 10s;
|
||
|
||
# 禁用缓存
|
||
proxy_cache off;
|
||
}
|
||
|
||
# Web前端静态文件
|
||
location / {
|
||
root C:/Claw/web; # 指向Web前端构建目录
|
||
index index.html index.htm;
|
||
try_files $uri $uri/ /index.html;
|
||
|
||
# 静态文件缓存
|
||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
|
||
expires 1y;
|
||
add_header Cache-Control "public, immutable";
|
||
}
|
||
}
|
||
|
||
# 健康检查端点
|
||
location /health {
|
||
access_log off;
|
||
return 200 "healthy\n";
|
||
add_header Content-Type text/plain;
|
||
}
|
||
}
|
||
|
||
# 上游服务器配置
|
||
upstream gateway_backend {
|
||
server 127.0.0.1:8000 max_fails=3 fail_timeout=30s;
|
||
keepalive 32;
|
||
}
|
||
} |