🇨🇳 The IP address in Discourse’s user information shows CloudFlare’s IP address | Discourse 的用户信息中的 IP 地址显示的是 CloudFlare 的 IP 地址

AI 生成的摘要

The discussion revolves around Discourse displaying CloudFlare’s IP address instead of the user’s real IP, caused by CloudFlare’s reverse proxy. honeymoose explains that this can be resolved by configuring Discourse with a cloudflare.template.yml file and rebuilding the instance using ./launcher rebuild app. sober reports intermittent 502 errors and slower performance when using CloudFlare with a Chinese server, which honeymoose attributes to server response time. sober later resolves the issue by fixing TCP load balancing but ultimately abandons CloudFlare due to performance issues. honeymoose suggests that without ICP备案, Tencent’s acceleration might be better than CloudFlare. sober notes Tencent’s service is costly. honeymoose shares that their Tencent acceleration cost is under 5 yuan per month. 5804829 encounters a boot failure on Rocky 9.3 when adding CloudFlare IPs, but it resolves after a server restart. honeymoose suspects Docker or OS version issues, while 5804829 notes the problem occurs on Alibaba Cloud but not on other platforms, possibly due to modified OS versions. honeymoose links to a similar issue on Discourse Meta. The thread also briefly touches on a Bilibili video plugin issue, with honeymoose suggesting an alternative solution, and joo noting the plugin is no longer user-friendly.

因为使用了 CloudFlare 的反向地址。

所有 Discourse 获得的用户的 IP 地址其实是 CloudFlare 的服务器地址。

修改

好在 Discourse 已经提供了相关的解决方案。

需要在 Discourse 的配置文件中,添加下面的内容:

  • “templates/cloudflare.template.yml”


然后重新 Build 你的 Discourse 的安装实例。

./launcher rebuild app

使用上面的命令就可以对 Discourse 直接进行重构了,需要注意的是重构需要 10 分钟左右,这 10 分钟系统是无法访问的。

重新刷新系统后进行查看,系统已经能够获取到正常的 IP 地址了。

2 个赞

大佬这个用的是CloudFlare的cdn 代理加速吗,我这边怎么总是出现CloudFlare到源服务器502提示,偶尔可以通,源服务器在中国,是网络问题,还是ssl证书问题,或者CloudFlare配置需要注意什么

我使用的是 CloudFlare 服务。

到目前为止没有出现 502 错误,应该可能是你的源服务器的响应时间超过了设定值。

问题查到了,我通过tcp负载均衡做内网转发,没有配置好,后面处理好了。但是源服务器在中国,使用CloudFlare反而变慢了,目前已经放弃了CloudFlare。内网转发也涉及到用户ip地址的解析,使用real_ip_header proxy_protocol解析到了

2 个赞

有 ICP 备案的问题,如果是国内的服务器,没有备案问题,用腾讯的全站数据加速可能比 CloudFlare 更好。

备案处理好了,试了阿里的,加速没问题,就是收费挺贵的,腾讯收费怎么样,看CloudFlare是免费的

谈不上便宜,这个网站:https://www.cwikius.cn/ 我们挂了腾讯的加速,本来也没啥流量。

一个月现在是小于 5 元。

了解,感谢大佬的反馈支持

以前用ubuntu的时候加这一行就可以看到真实ip 可是用rocky 9.3的话,加这一行,就无法重新启动了。

有可能是操作系统版本的问题吧。

官方自己用的是 ubuntu,但是也是部署在容器上的,和你用什么操作系统应该影响不大。

我换成ubuntu22.04 还是一样的报错
FAILED

Pups::ExecError: /tmp/add-cloudflare-ips failed with return #<Process::Status: pid 4279 exit 8>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn’
exec failed with the params “/tmp/add-cloudflare-ips”
bootstrap failed with exit code 8
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.

貌似是 Discourse 在执行的时候有什么错误,在服务器上装 Docker 容器了吗?

那么 Docker 的版本是多少呢?

Docker 版本 26.0.0,构建版本 2ae903e

以前用甲骨云就没事 现在是阿里云就不行 难道是阿里云有什么安全措施?!

有可能是这样的。

国内的很多操作系统版本是魔改过的。一些东西没有办法用。

最后在一次重启服务器的情况下 竟然莫名其妙的又好了…

那这个也很奇葩了。光看着错误也是看不出什么东西。

Pups::ExecError: /tmp/add-cloudflare-ips failed with return #<Process::Status: pid 5134 exit 8>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn’
exec failed with the params “/tmp/add-cloudflare-ips”
bootstrap failed with exit code 8
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
f51291d274ba2564076ba412f28fb445db9c916f00a6d1fb76d2613e773ccfcf
不知道这是什么情况!!!

好像别人也有过这个问题,你参考下这个:Failed to bootstrap (/tmp/add-cloudflare-ips) - #21 by GreenOWL

大佬有没有解析b站视频的呢?之前用的插件现在好像不行了