使用1panel 容器部署discourse,并使用反向代理建设网站,域名使用cloudflare cdn 后,如何解决所有流量显示为来自 Cloudflare 的服务器,而不是用户的浏览器 IP。
您想在 app.yml 中使用 Cloudflare 模板。
试过了,不行呢
。失败的原因可能是我是使用1panel容器部署的,并使用了反向代理?
您可以直接编辑 nginx 配置文件吗?如果可以,请按照此处的建议进行修改。重新加载 nginx 服务后,问题应该就能解决。希望这能帮到您!
很好奇为什么要运行两个反向代理?一个在托管公司,另一个是 CloudFlare。有技术原因吗?
我是用服务器管理面板1panel(开源)容器化部署的discourse,方便服务器管理。
1Panel 的架构是:用户 -> Cloudflare -> 1Panel Nginx -> Discourse 容器
我的理解是即使修改了 Discourse 的app.yml配置,1Panel 的 Nginx 依然在 Cloudflare 和 Discourse 之间挡着。
因此,这是由 1panel 引入的技术限制。
您是在 VPS 上运行多个服务器,还是仅运行 Discourse?如果您仅运行 Discourse,可能并不需要 1panel。除非您有必须使用 1panel 的技术原因。
我的 Discourse 实例是原生部署在 VPS 上,并通过 Cloudflare 进行保护。此配置运行正常。
除了discourse,还有openclaw ![]()
几乎可以肯定是这样。
你看到的 IP 是 1panel 容器的 IP 吗?
使用管理员查看用户 ,最后使用的ip地址显示是cloudflare的ip地址。
您是否已实施此方案?
这是针对 Apache 的修复方案,用于使用最终用户的 IP 地址,而非 Cloudflare 的 IP 地址。
谢谢,我使用的是nginx,我查了一些教程,是设置反向代理宿主机的nginx配置文件,等找时间我试试。
您是否按照建议安装了 Cloudflare 模板?如果没有,那您为什么在这里寻求帮助呢?
Cloudflare 模板?我已经修改了yml配置文件,启用了cloudflare模板,只不过我是通过1panel 容器化部署的discourse(1Panel 的架构是:用户 → Cloudflare → 1Panel Nginx → Discourse 容器),只改yml文件是不行的,还要该1panel里面反向代理NGINX的配置文件,我现在没有时间,还没动手改。
It sounds like you need to modify 1Panel’s instance of nginx to utilize its real_ip functionality for user requests. Cloudflare sends along this information with the CF-Connecting-IP header, and you can utilize that header to tell nginx what to do with itself.
It would likely be worthwhile to build some script-based automation to regularly download cloudflare’s proxy address lists (ipv4, ipv6) to keep your nginx real_ip ranges updated.
If you don’t have access to your 1Panel nginx.conf file, you’re probably out of luck. Nginx’s real_ip + cloudflare’s CF-Connecting-IP header is how this problem is intended to be solved if you’re managing your own reverse proxy in front of self-hosted Discourse.