Files
wechatAiclaw/docs/nginx-example.conf
2026-03-15 17:59:56 +08:00

49 lines
1.8 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 反向代理示例(前置到 Docker 容器)
# 502 Bad Gateway 通常表示 nginx 连不上上游,请按下方排查。
#
# 常见原因:
# 1. proxy_pass 的端口与宿主机映射不一致run-docker.sh 默认 -p 3003:3000 -p 8008:8000
# 则宿主机上前端是 3003、后端是 8008若用 -p 3000:3000则前端是 3000。
# 2. 上游写成了容器内端口:若 nginx 与 Docker 在同一台机,应写 127.0.0.1:宿主机端口(如 3003
# 不要写 127.0.0.1:3000除非宿主机映射就是 3000:3000
# 3. 容器或容器内进程未启动docker logs wechat-admin-backend 查看是否有报错。
# 4. 防火墙或安全组未放行宿主机端口。
# 假设宿主机映射为:前端 3003、后端 8008与 run-docker.sh 默认一致)
upstream wechat_frontend {
server 127.0.0.1:3003;
keepalive 32;
}
upstream wechat_backend {
server 127.0.0.1:8008;
keepalive 32;
}
server {
listen 80;
server_name your-domain.com;
# 前端静态 + Node 代理
location / {
proxy_pass http://wechat_frontend;
proxy_http_version 1.1;
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 Connection "";
}
# 后端 API可选若希望 /api 直接打到后端可单独配置)
location /api/ {
proxy_pass http://wechat_backend/api/;
proxy_http_version 1.1;
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 Connection "";
}
}