fix: 修复生产环境
This commit is contained in:
48
docs/nginx-example.conf
Normal file
48
docs/nginx-example.conf
Normal file
@@ -0,0 +1,48 @@
|
||||
# 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 "";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user