无法引导 (/tmp/add-cloudflare-ips)

你好!

尝试重建时出现此错误:

FAILED
--------------------
Pups::ExecError: /tmp/add-cloudflare-ips 失败,返回 #<Process::Status: pid 1484 exit 8>
失败位置:/usr/local/lib/ruby/gems/2.7.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec 失败,参数为 “/tmp/add-cloudflare-ips”
9fe8337bb7b8e64abb480bd2527551585759e48df340dc74bb84c67bdf1ee6b2
**引导失败** 请向上滚动并查找更早的错误消息,可能不止一个。
./discourse-doctor 可能有助于诊断问题。

在 CloudFlare 上启用和禁用代理(橙色云)时,此错误是安全的 :frowning:

1 个赞

你能向上滚动并显示上面 /tmp/add-cloudflare-ips 命令失败的输出吗?

已完成 CSS 编译:2022-03-22 16:54:37 UTC
I, [2022-03-22T16:54:37.832057 #1]  INFO -- : Downloading MaxMindDB...
正在压缩 Javascript 并生成 Source Maps

I, [2022-03-22T16:54:37.874506 #1]  INFO -- : File > /usr/local/bin/discourse  chmod: +x  chown:
I, [2022-03-22T16:54:37.880784 #1]  INFO -- : File > /usr/local/bin/rails  chmod: +x  chown:
I, [2022-03-22T16:54:37.887872 #1]  INFO -- : File > /usr/local/bin/rake  chmod: +x  chown:
I, [2022-03-22T16:54:37.894248 #1]  INFO -- : File > /usr/local/bin/rbtrace  chmod: +x  chown:
I, [2022-03-22T16:54:37.900136 #1]  INFO -- : File > /usr/local/bin/stackprof  chmod: +x  chown:
I, [2022-03-22T16:54:37.907873 #1]  INFO -- : File > /etc/update-motd.d/10-web  chmod: +x  chown:
I, [2022-03-22T16:54:37.912825 #1]  INFO -- : File > /etc/logrotate.d/rails  chmod:   chown:
I, [2022-03-22T16:54:37.917132 #1]  INFO -- : File > /etc/logrotate.d/nginx  chmod:   chown:
I, [2022-03-22T16:54:37.924129 #1]  INFO -- : File > /etc/runit/1.d/00-ensure-links  chmod: +x  chown:
I, [2022-03-22T16:54:37.930083 #1]  INFO -- : File > /etc/runit/1.d/01-cleanup-web-pids  chmod: +x  chown:
I, [2022-03-22T16:54:37.936780 #1]  INFO -- : File > /root/.bash_profile  chmod: 644  chown:
I, [2022-03-22T16:54:37.941664 #1]  INFO -- : File > /usr/local/etc/ImageMagick-7/policy.xml  chmod:   chown:
I, [2022-03-22T16:54:37.949303 #1]  INFO -- : Replacing (?-mix:server.+{) with limit_req_zone $binary_remote_addr zone=flood:10m rate=$reqs_per_secondr/s;
limit_req_zone $binary_remote_addr zone=bot:10m rate=$reqs_per_minute r/m;
limit_req_status 429;
limit_conn_zone $binary_remote_addr zone=connperip:10m;
limit_conn_status 429;
server {
 in /etc/nginx/conf.d/discourse.conf
I, [2022-03-22T16:54:37.952599 #1]  INFO -- : Replacing (?-mix:location @discourse {) with location @discourse {
  limit_conn connperip $conn_per_ip;
  limit_req zone=flood burst=$burst_per_second nodelay;
  limit_req zone=bot burst=$burst_per_minute nodelay; in /etc/nginx/conf.d/discourse.conf
I, [2022-03-22T16:54:37.960935 #1]  INFO -- : File > /tmp/add-cloudflare-ips  chmod: +x  chown:
I, [2022-03-22T16:54:37.961856 #1]  INFO -- : > /tmp/add-cloudflare-ips
--2022-03-22 16:54:37--  https://www.cloudflare.com/ips-v4/
Resolving www.cloudflare.com (www.cloudflare.com)... 104.16.124.96, 104.16.123.96, 2606:4700::6810:7c60, ...
Connecting to www.cloudflare.com (www.cloudflare.com)|104.16.124.96|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2022-03-22 16:54:38 ERROR 403: Forbidden.

I, [2022-03-22T16:54:38.130543 #1]  INFO -- :
I, [2022-03-22T16:54:38.146489 #1]  INFO -- : Terminating async processes
I, [2022-03-22T16:54:38.148916 #1]  INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main pid: 42
2022-03-22 16:54:38.149 UTC [42] LOG:  received fast shutdown request
I, [2022-03-22T16:54:38.150508 #1]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 103
103:signal-handler (1647968078) Received SIGTERM scheduling shutdown...
2022-03-22 16:54:38.155 UTC [42] LOG:  aborting any active transactions
2022-03-22 16:54:38.167 UTC [42] LOG:  background worker "logical replication launcher" (PID 51) exited with exit code 1
2022-03-22 16:54:38.171 UTC [46] LOG:  shutting down
103:M 22 Mar 2022 16:54:38.203 # User requested shutdown...
103:M 22 Mar 2022 16:54:38.204 * Saving the final RDB snapshot before exiting.
103:M 22 Mar 2022 16:54:38.213 * DB saved on disk
103:M 22 Mar 2022 16:54:38.214 # Redis is now ready to exit, bye bye...
2022-03-22 16:54:38.228 UTC [42] LOG:  database system is shut down


FAILED
--------------------
Pups::ExecError: /tmp/add-cloudflare-ips failed with return #<Process::Status: pid 1487 exit 8>
Location of failure: /usr/local/lib/ruby/gems/2.7.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params "/tmp/add-cloudflare-ips"
3123cbaef859e04ff382e3194e1745b88ee6e4777de9f0f7b45cb6cf2ac6d757
** 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.
root@app:/var/discourse#

Cloudflare 已阻止您的 IP 地址检索其 IP 地址列表。您可以重试、询问原因或自行管理列表。

要解决当前问题,我可能会从本地计算机检索列表,并将模板改编为将其硬编码而不是从 Cloudflare 检索,然后与他们联系。

@RyanK 有什么建议吗?我们的 模板 会在每次构建时拉取列表,但这不应该是个问题。我预计如果出现问题,应该会收到 429 速率限制错误,而不是 403 错误。

3 个赞

抱歉,我不太懂,我该如何添加 CloudFlare IP 地址而不使用 cloudflare.template.yml 这个模板?我使用的是 Discourse Docker 在 Ubuntu 20.04 上。

我在两个独立的实例上遇到了相同的问题,IP 地址也不同。@GreenOWL 你使用的是哪个数据中心?

1 个赞

如果 Cloudflare 阻止了您的访问,并且您不熟悉手动修复,我强烈建议您移除 Cloudflare 的代理。

4 个赞

会给滥用者打开地狱之门。

1 个赞

您的托管提供商数据中心。

1 个赞

除非你运营一个吸引施虐者的社区,否则这不应该是个问题。以一种不泄露你IP地址的方式运行Discourse相当棘手。

变体 2。

如果你帮不了忙——就别冒犯用户了。

实际上,模板操作可以通过从另一个 IP 获取 CF IP 来手动嵌入。@Falco 给了你一个可靠的建议。

是的,vultr也是。我猜你应该给他们发个工单,说明是他们所有IP的问题。

在您的 yaml 中检查挂载卷的位置。

我尝试在 cloudflare.template.yml 中将 URL cloudflare.com/ips-v4/, cloudflare.com/ips-v6/ 替换为我的服务器上的 IP(托管 IP 列表时)。

contents: |
        #!/bin/bash -e
        # Download list of CloudFlare ips
        wget -q https://www.myserver.com/ips-v4/ -O - > /tmp/cloudflare-ips
        echo >> /tmp/cloudflare-ips
        wget -q https://www.myserver.com/ips-v6/ -O - >> /tmp/cloudflare-ips
        # Make into nginx commands and escape for inclusion into sed append command
        CONTENTS=$(</tmp/cloudflare-ips sed '/^$/d; s/^.*/set_real_ip_from \u0026;/' | tr '\n' '\\' | sed 's/\\\\/\\\\n/g')

有这个结果

I, [2022-03-22T18:49:10.469231 #1]  INFO -- : Downloading MaxMindDB...
Compressing Javascript and Generating Source Maps

I, [2022-03-22T18:49:10.514524 #1]  INFO -- : File > /usr/local/bin/discourse  chmod: +x  chown:
I, [2022-03-22T18:49:10.521050 #1]  INFO -- : File > /usr/local/bin/rails  chmod: +x  chown:
I, [2022-03-22T18:49:10.528727 #1]  INFO -- : File > /usr/local/bin/rake  chmod: +x  chown:
I, [2022-03-22T18:49:10.534748 #1]  INFO -- : File > /usr/local/bin/rbtrace  chmod: +x  chown:
I, [2022-03-22T18:49:10.541288 #1]  INFO -- : File > /usr/local/bin/stackprof  chmod: +x  chown:
I, [2022-03-22T18:49:10.549718 #1]  INFO -- : File > /etc/update-motd.d/10-web  chmod: +x  chown:
I, [2022-03-22T18:49:10.554428 #1]  INFO -- : File > /etc/logrotate.d/rails  chmod:   chown:
I, [2022-03-22T18:49:10.558589 #1]  INFO -- : File > /etc/logrotate.d/nginx  chmod:   chown:
I, [2022-03-22T18:49:10.565929 #1]  INFO -- : File > /etc/runit/1.d/00-ensure-links  chmod: +x  chown:
I, [2022-03-22T18:49:10.571595 #1]  INFO -- : File > /etc/runit/1.d/01-cleanup-web-pids  chmod: +x  chown:
I, [2022-03-22T18:49:10.578243 #1]  INFO -- : File > /root/.bash_profile  chmod: 644  chown:
I, [2022-03-22T18:49:10.583602 #1]  INFO -- : File > /usr/local/etc/ImageMagick-7/policy.xml  chmod:   chown:
I, [2022-03-22T18:49:10.589959 #1]  INFO -- : Replacing (?-mix:server.+{) with limit_req_zone $binary_remote_addr zone=flood:10m rate=$reqs_per_secondr/s;
limit_req_zone $binary_remote_addr zone=bot:10m rate=$reqs_per_minuter/m;
limit_req_status 429;
limit_conn_zone $binary_remote_addr zone=connperip:10m;
limit_conn_status 429;
server {
 in /etc/nginx/conf.d/discourse.conf
I, [2022-03-22T18:49:10.592764 #1]  INFO -- : Replacing (?-mix:location @discourse {) with location @discourse {
  limit_conn connperip $conn_per_ip;
  limit_req zone=flood burst=$burst_per_second nodelay;
  limit_req zone=bot burst=$burst_per_minute nodelay; in /etc/nginx/conf.d/discourse.conf
I, [2022-03-22T18:49:10.601940 #1]  INFO -- : File > /tmp/add-cloudflare-ips  chmod: +x  chown:
I, [2022-03-22T18:49:10.604368 #1]  INFO -- : > /tmp/add-cloudflare-ips
I, [2022-03-22T18:49:10.791696 #1]  INFO -- :
I, [2022-03-22T18:49:10.811681 #1]  INFO -- : Terminating async processes
I, [2022-03-22T18:49:10.813970 #1]  INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main pid: 42
2022-03-22 18:49:10.815 UTC [42] LOG:  received fast shutdown request
I, [2022-03-22T18:49:10.816541 #1]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 103
103:signal-handler (1647974950) Received SIGTERM scheduling shutdown...
2022-03-22 18:49:10.820 UTC [42] LOG:  aborting any active transactions
2022-03-22 18:49:10.834 UTC [42] LOG:  background worker "logical replication launcher" (PID 51) exited with exit code 1
2022-03-22 18:49:10.837 UTC [46] LOG:  shutting down
2022-03-22 18:49:10.877 UTC [42] LOG:  database system is shut down
103:M 22 Mar 2022 18:49:10.896 # User requested shutdown...
103:M 22 Mar 2022 18:49:10.897 * Saving the final RDB snapshot before exiting.
103:M 22 Mar 2022 18:49:10.923 * DB saved on disk
103:M 22 Mar 2022 18:49:10.924 # Redis is now ready to exit, bye bye...


FAILED
--------------------
Pups::ExecError: /tmp/add-cloudflare-ips failed with return #<Process::Status: pid 1487 exit 8>
Location of failure: /usr/local/lib/ruby/gems/2.7.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params "/tmp/add-cloudflare-ips"
7b755fd1f149c4b1bfb984edccf952001a7d97621aba59a111d07784bf39dc78
** 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.

将现有的 cloudflare.template.yml 复制到 cloudflare-static.template.yml,并替换顶部内容,使其如下所示:

run:
  - file:
      path: /tmp/add-cloudflare-ips
      chmod: +x
      contents: |
        #!/bin/bash -e
        cat <<EOF > /tmp/cloudflare-ips
        173.245.48.0/20
        103.21.244.0/22
        103.22.200.0/22
        103.31.4.0/22
        141.101.64.0/18
        108.162.192.0/18
        190.93.240.0/20
        188.114.96.0/20
        197.234.240.0/22
        198.41.128.0/17
        162.158.0.0/15
        104.16.0.0/13
        104.24.0.0/14
        172.64.0.0/13
        131.0.72.0/22
        2400:cb00::/32
        2606:4700::/32
        2803:f800::/32
        2405:b500::/32
        2405:8100::/32
        2a06:98c0::/29
        2c0f:f248::/32
        EOF
        # 转换为 nginx 命令并转义以包含在 sed 追加命令中
        CONTENTS=$(< /tmp/cloudflare-ips sed '/^$/d; s/^.*/set_real_ip_from &;/' | tr '\n' '\\\\' | sed 's/\\\\/\\\\n/g')

        echo CloudFlare IPs:
        echo $(echo | sed "/^/a $CONTENTS")
        # 插入 discourse.conf
        sed -i "/sendfile on;/a $CONTENTS\\nreal_ip_header CF-Connecting-IP;" /etc/nginx/conf.d/discourse.conf
        # 清理
        rm /tmp/cloudflare-ips

  - exec: "/tmp/add-cloudflare-ips"
  - exec: "rm /tmp/add-cloudflare-ips"

然后将您的应用程序容器更改为使用 -static 模板而不是原始模板。

不要永远这样放着。

4 个赞

我可以在 cloudflare.template.yml 中修复它

我使用 GitHub 来托管 CloudFlare IP 列表,并因为使用了带 / 符号的链接而遇到此错误

        # Download list of CloudFlare ips
        wget https://raw.githubusercontent.com/xxx-cloud/CloudFlare-IPs/main/ips-v4/ -O - > /tmp/cloudflare-ips
        echo >> /tmp/cloudflare-ips
        wget https://raw.githubusercontent.com/xxx-cloud/CloudFlare-IPs/main/ips-v6/ -O - >> /tmp/cloudflare-ips

需要去掉 URL 末尾的 /

        # Download list of CloudFlare ips
        wget https://raw.githubusercontent.com/xxx-cloud/CloudFlare-IPs/main/ips-v4 -O - > /tmp/cloudflare-ips
        echo >> /tmp/cloudflare-ips
        wget https://raw.githubusercontent.com/xxx-cloud/CloudFlare-IPs/main/ips-v6 -O - >> /tmp/cloudflare-ips

它能工作 :slight_smile:

我认为从这个角度来看,需要为 CloudFlare IP 网站 https://www.cloudflare.com/ips-v4https://www.cloudflare.com/ips-v6 创建一个镜像,以获取最新列表并绕过阻止。

1 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.