Commit d38bf227 by Xianquan Committed by GitHub

docs: add client IP proxy troubleshooting notes (#7102)

parent 21dc72a0
......@@ -8,20 +8,111 @@ description: FastGPT usage notes
If you encounter issues while using FastGPT, follow the steps below to troubleshoot and resolve them.
## 1. Check Version and Upgrade
Many known issues are fixed in newer releases. Before reporting a problem, verify your version first:
- **Check version**: View the current running version on the FastGPT homepage or in the admin panel.
- **Upgrade recommendation**: If you are not on the latest version, follow the [Upgrade Guide](../upgrading/upgrade-intruction) to update to the latest stable release.
- **Check version:** View the current running version on the FastGPT homepage or in the admin panel.
- **Upgrade recommendation:** If you are not on the latest version, follow the [Upgrade Guide](../upgrading/upgrade-intruction) to update to the latest stable release.
## 2. Troubleshooting Steps
If the issue still exists after upgrading, check in this order:
- **Check logs**: Review Docker container logs or server logs and locate the specific error stack.
- **Clear cache**: Clear browser cache or retry in incognito mode.
- **Environment check**: Ensure MongoDB and PostgreSQL/Milvus connections are healthy and API keys are valid.
## 3. Contact Technical Support
- **Check logs:** Review Docker container logs or server logs and locate the specific error stack.
- **Clear cache:** Clear browser cache or retry in incognito mode.
- **Environment check:** Ensure MongoDB and PostgreSQL/Milvus connections are healthy and API keys are valid.
## 3. Prevent Spoofed Client IPs Behind a Reverse Proxy
FastGPT reads the client IP for IP rate limiting, share-link IP allowlists, chat log IP records, and IP geolocation. If your self-hosted FastGPT is behind Nginx, a load balancer, an Ingress controller, or a CDN, make sure clients cannot spoof `X-Forwarded-For` or `X-Real-IP` headers.
Recommended setup:
- **Overwrite incoming IP headers in Nginx:** the last reverse proxy should not pass through a user-supplied `X-Forwarded-For` header. It should overwrite the header with the real connection source.
- **Enable trusted proxy validation in FastGPT:** trust forwarded IP headers only when they come from Nginx, the load balancer, or the Ingress controller.
- **Restrict direct access to FastGPT:** firewall or security group rules should allow only the reverse proxy to access the FastGPT service port.
FastGPT environment variable example:
```dotenv
TRUSTED_PROXY_ENABLE=true
TRUSTED_PROXY_IPS=172.18.0.0/16
```
`TRUSTED_PROXY_IPS` should contain the previous-hop proxy IP or CIDR that FastGPT sees directly, such as the Docker subnet for the Nginx container, the Ingress Controller private address, or the load balancer origin address. Do not use a trust-all CIDR such as `0.0.0.0/0` because it would trust every source, and do not add normal client networks to the trusted list.
For a single Nginx layer exposed directly to users, use:
```nginx
server {
listen 80;
server_name fastgpt.example.com;
location / {
proxy_pass http://fastgpt:3000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
```
If a CDN or load balancer is in front of Nginx, configure Nginx to trust only those upstream egress IPs first. Then forward the restored client IP to FastGPT:
```nginx
server {
listen 80;
server_name fastgpt.example.com;
# Add only your CDN or load balancer egress IP/CIDR ranges. Do not trust every source.
set_real_ip_from 10.0.0.0/8;
set_real_ip_from 172.16.0.0/12;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
location / {
proxy_pass http://fastgpt:3000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
```
If your CDN uses a dedicated real-IP header, use that header in `real_ip_header` and set `set_real_ip_from` to the official egress IP ranges published by the CDN. Cloudflare uses `CF-Connecting-IP` as one example.
After updating Nginx, run:
```bash
nginx -t && nginx -s reload
```
You can verify the setup with spoofed headers:
```bash
curl -H 'X-Forwarded-For: 6.6.6.6' -H 'X-Real-IP: 6.6.6.6' https://fastgpt.example.com
```
If the configuration is correct, FastGPT should still record and validate the real client IP, not the spoofed value `6.6.6.6` from the request.
## 4. Contact Technical Support
If the issue still cannot be resolved, contact us through:
- **Community feedback**: Search for similar issues in GitHub Issues or community channels.
- **Provide details**: When contacting support, include:
- **Community feedback:** Search for similar issues in GitHub Issues or community channels.
- **Provide details:** When contacting support, include:
- Full version number currently in use.
- Detailed issue description with reproduction steps.
- Related system error logs or screenshots.
......@@ -8,18 +8,109 @@ description: FastGPT注意事项
在使用 FastGPT 过程中遇到问题时,请参考以下步骤进行排查和解决。
## 1. 版本检查与升级
很多已知问题已在最新版本中得到修复。在反馈问题前,请务必确认您的版本情况:
- **检查版本**:在 FastGPT 首页或管理后台查看当前运行的版本号。
- **升级建议**:如果当前不是最新版本,建议先参考 [更新指南](../upgrading/upgrade-intruction) 升级至最新稳定版。
## 2. 问题排查步骤
若升级后问题依然存在,请按以下顺序排查:
- **查看日志**:检查 Docker 容器或服务器日志,寻找具体的错误报错信息(Error Stack)。
- **清理缓存**:尝试清理浏览器缓存或使用无痕模式重新访问。
- **环境检查**:确认数据库(MongoDB, PostgreSQL/Milvus)连接是否正常,以及 API 密钥是否有效。
## 3. 联系技术支持
## 3. 反向代理客户端 IP 防伪造
FastGPT 会在 IP 限流、分享链接 IP 白名单、对话日志 IP 记录、IP 属地展示等场景读取客户端 IP。自部署时如果 FastGPT 前面有 Nginx、负载均衡、Ingress 或 CDN,需要避免客户端伪造 `X-Forwarded-For` 或 `X-Real-IP` 请求头。
推荐同时完成以下配置:
- **Nginx 覆盖外部传入的 IP 请求头**:最后一层反向代理不要透传用户原始 `X-Forwarded-For`,而是用真实连接来源覆盖。
- **FastGPT 开启可信代理校验**:只信任来自 Nginx、负载均衡或 Ingress 的转发头,不信任普通客户端直连请求里的 IP 头。
- **限制 FastGPT 端口暴露范围**:防火墙或安全组只允许反向代理访问 FastGPT 服务端口,避免用户绕过 Nginx 直连 FastGPT。
FastGPT 环境变量示例:
```dotenv
TRUSTED_PROXY_ENABLE=true
TRUSTED_PROXY_IPS=172.18.0.0/16
```
`TRUSTED_PROXY_IPS` 需要填写 FastGPT 直接看到的上一跳代理 IP 或 CIDR,例如 Nginx 容器所在 Docker 网段、Ingress Controller 内网地址或负载均衡回源地址。不要填写 `0.0.0.0/0`,也不要把普通客户端网段加入可信列表。
单层 Nginx 直接对外时,可参考:
```nginx
server {
listen 80;
server_name fastgpt.example.com;
location / {
proxy_pass http://fastgpt:3000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
```
如果 Nginx 前面还有 CDN 或负载均衡,需要先让 Nginx 只信任这些上游的出口 IP,再把还原后的真实客户端 IP 转发给 FastGPT:
```nginx
server {
listen 80;
server_name fastgpt.example.com;
# 只填写你的 CDN 或负载均衡出口 IP/CIDR,不要信任所有来源。
set_real_ip_from 10.0.0.0/8;
set_real_ip_from 172.16.0.0/12;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
location / {
proxy_pass http://fastgpt:3000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
```
如果 CDN 使用专用真实 IP 头,例如 `CF-Connecting-IP`,需要把 `real_ip_header` 改成对应头名,并把 `set_real_ip_from` 配置为该 CDN 官方公布的出口 IP 段。
修改完成后,执行:
```bash
nginx -t && nginx -s reload
```
可以用伪造头验证配置是否生效:
```bash
curl -H 'X-Forwarded-For: 6.6.6.6' -H 'X-Real-IP: 6.6.6.6' https://fastgpt.example.com
```
如果配置正确,FastGPT 记录和校验的仍应是真实客户端 IP,而不是 `6.6.6.6`。
## 4. 联系技术支持
若以上步骤均无法解决您的问题,请通过以下方式联系我们:
- **社区反馈**:在 GitHub Issues 或相关社群中搜索类似问题。
- **提供信息**:联系技术人员时,请务必提供:
- 当前使用的完整版本号。
......
......@@ -59,8 +59,8 @@
"content/guide/build/workflow/nodes/laf.mdx": "2026-05-07T15:06:40+08:00",
"content/guide/build/workflow/nodes/loop.en.mdx": "2026-05-07T15:06:40+08:00",
"content/guide/build/workflow/nodes/loop.mdx": "2026-05-07T15:06:40+08:00",
"content/guide/build/workflow/nodes/loop_run.en.mdx": "2026-06-11T13:33:07+08:00",
"content/guide/build/workflow/nodes/loop_run.mdx": "2026-06-11T13:33:07+08:00",
"content/guide/build/workflow/nodes/loop_run.en.mdx": "2026-06-12T00:30:58+08:00",
"content/guide/build/workflow/nodes/loop_run.mdx": "2026-06-12T00:30:58+08:00",
"content/guide/build/workflow/nodes/parallel_run.en.mdx": "2026-05-07T15:06:40+08:00",
"content/guide/build/workflow/nodes/parallel_run.mdx": "2026-05-07T15:06:40+08:00",
"content/guide/build/workflow/nodes/question_classify.en.mdx": "2026-05-07T15:06:40+08:00",
......@@ -276,8 +276,8 @@
"content/self-host/upgrading/4-15/41503.mdx": "2026-05-28T16:21:09+08:00",
"content/self-host/upgrading/4-15/41504.en.mdx": "2026-06-10T19:02:59+08:00",
"content/self-host/upgrading/4-15/41504.mdx": "2026-06-11T17:42:15+08:00",
"content/self-host/upgrading/4-15/41505.en.mdx": "2026-06-11T23:20:26+08:00",
"content/self-host/upgrading/4-15/41505.mdx": "2026-06-11T23:20:26+08:00",
"content/self-host/upgrading/4-15/41505.en.mdx": "2026-06-12T00:30:58+08:00",
"content/self-host/upgrading/4-15/41505.mdx": "2026-06-12T00:30:58+08:00",
"content/self-host/upgrading/outdated/40.en.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/upgrading/outdated/40.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/upgrading/outdated/41.en.mdx": "2026-04-26T21:08:47+08:00",
......@@ -418,6 +418,6 @@
"content/self-host/upgrading/outdated/499.mdx": "2026-05-07T15:06:40+08:00",
"content/self-host/upgrading/upgrade-intruction.en.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/upgrading/upgrade-intruction.mdx": "2026-04-26T21:08:47+08:00",
"content/toc.en.mdx": "2026-06-11T23:20:26+08:00",
"content/toc.mdx": "2026-06-11T23:20:26+08:00"
"content/toc.en.mdx": "2026-06-12T00:30:58+08:00",
"content/toc.mdx": "2026-06-12T00:30:58+08:00"
}
\ No newline at end of file
Subproject commit cd209c713a0263acb08492738c2c4265d8dc37b9
Subproject commit 0f49c306a09ba34ea427643dd81d7939cd80985f
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment