The IP address in Discourse’s user information shows CloudFlare’s IP address

Because CloudFlare’s reverse address is used.

The IP addresses obtained by all Discourse users are actually the IP addresses of CloudFlare’s servers.

Modification

Fortunately, Discourse has already provided a solution.

You need to add the following content to Discourse’s configuration file:

  • “templates/cloudflare.template.yml”

Then rebuild your Discourse installation instance.

./launcher rebuild app

The above command can be used to directly rebuild Discourse. It should be noted that the rebuild takes about 10 minutes, during which the system is inaccessible.

Refresh the system again to check, and the system can now obtain the correct IP address.

2 Likes

Boss, is this using CloudFlare’s CDN proxy acceleration? Why am I always getting a 502 error from CloudFlare to the origin server? It occasionally works. The origin server is in China. Is it a network issue, an SSL certificate issue, or are there any CloudFlare configurations to pay attention to?

I am using CloudFlare services.

There have been no 502 errors so far, it is likely that your origin server’s response time has exceeded the set value.

The problem has been found. I was using TCP load balancing for internal forwarding and it was not configured correctly. It has since been fixed. However, the origin server is in China, and using CloudFlare actually made it slower. I have now abandoned CloudFlare. Internal forwarding also involves parsing the user IP address, which was resolved using real_ip_header proxy_protocol.

2 Likes

There are ICP filing issues. If it is a domestic server, there are no filing issues. Using Tencent’s full-site data acceleration may be better than CloudFlare.

The filing has been processed. I tried Alibaba’s, and the acceleration is fine, but it’s quite expensive. How is Tencent’s pricing? Cloudflare is free.

It’s not exactly cheap. This website: https://www.cwikius.cn/ uses Tencent’s acceleration service. We didn’t have much traffic to begin with.

It’s currently less than 5 yuan per month.

Understood, thank you for your feedback and support.

When I used Ubuntu, adding this line allowed me to see the real IP. However, when using Rocky 9.3, adding this line prevents it from restarting.

It might be an issue with the operating system version.

The official version uses Ubuntu, but it is also deployed in a container, so it should not significantly affect what operating system you use.

I switched to ubuntu22.04 and it’s still giving the same error
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.

It seems like there’s an error when Discourse is executing. Did you install Docker containers on the server?

What is the Docker version?

Docker version 26.0.0, build 2ae903e

I had no problems with Jiagu Cloud before, but now with Alibaba Cloud, it doesn’t work. Could it be that Alibaba Cloud has some security measures?!

It’s possible.

Many domestic operating system versions have been modified. Some things cannot be used.

Finally, after restarting the server, it inexplicably got better…

This is also very strange. Just looking at the error, I can’t tell what’s wrong.

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
I don’t know what’s going on!!!

It seems others have encountered this issue as well. Please refer to this: Failed to bootstrap (/tmp/add-cloudflare-ips) - #21 by GreenOWL

Does anyone have a Bilibili video parser? The plugin I used before doesn’t seem to work anymore.