guanghulab/server/corpus-agent/deploy-nginx.conf

81 lines
2.2 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.

# 语料采集系统 · Corpus Agent
# Nginx路由配置 —— 添加到 guanghulab-cvm.conf
# 语料采集服务 (Corpus-Agent)
# 内网地址: 127.0.0.1:8084 → 对外路径: /corpus/
# 需要替换 YOUR_CORPUS_TOKEN 为实际值
# 方案A有独立域名的子路径
# location /corpus/ {
# proxy_pass http://127.0.0.1:8084/;
# 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支持Mac客户端实时采集用
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
# proxy_read_timeout 86400;
# }
# 方案B直接绑定到 guanghulab.com/corpus
# 将以下代码插入到 /workspace/guanghulab/server/nginx/guanghulab-cvm.conf
"""
server {
listen 443 ssl;
server_name guanghulab.com;
# ... 已有配置 ...
# === 语料采集服务 ===
location /corpus/ {
proxy_pass http://127.0.0.1:8084/;
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_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
}
}
"""
# 部署步骤:
# 1. 将 corpus-agent 目录上传到服务器
# 2. 安装依赖: pip install -r requirements.txt
# 3. 配置 systemd 或 pm2 开机自启
# 4. 添加 nginx 路由
# 5. 重启 nginx
# PM2启动命令
# pm2 start "cd /path/to/corpus-agent && python3 server.py" --name corpus-agent
# Systemd Service:
"""
[Unit]
Description=Corpus Agent Service
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/path/to/corpus-agent
Environment=CORPUS_HOST=0.0.0.0
Environment=CORPUS_PORT=8084
Environment=CORPUS_DATA_DIR=/data/corpus
ExecStart=/usr/bin/python3 /path/to/corpus-agent/server.py
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
"""