מישהו יכול לעזור לי לנתח למה הוספת ה-real ip של cf מונעת rebuild?

סיכום מבוסס בינה מלאכותית

The user 5804829 is experiencing issues with rebuilding their Discourse installation after adding the Cloudflare template to their app.yml file. The error message indicates a failure in the /tmp/add-cloudflare-ips script.

User fokx suggests that the issue is likely due to a network problem causing the wget command in the script to fail. They recommend removing the Cloudflare line from app.yml, rebuilding, and then manually executing the commands in templates/cloudflare.template.yml inside the container.

User 5804829 asks if having a swap partition is necessary for the VPS, but fokx responds that the failure reason is unrelated to memory or swap. They also suggest searching for similar issues before asking, citing a related discussion on the Discourse meta forum: https://meta.discourse.org/t/failed-to-bootstrap-tmp-add-cloudflare-ips/221667/.

附件中是安装日志
Attached is the installation log

在app.yml 增加了 - “templates/cloudflare.template.yml”
log.txt (167.9 KB)

[root@iZj ~]# docker info
Client: Docker Engine - Community
 Version:    26.0.1
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.13.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.26.1
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 5
  Running: 0
  Paused: 0
  Stopped: 5
 Images: 5
 Server Version: 26.0.1
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: e377cd56a71523140ca6ae87e30244719194a521
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
 Kernel Version: 5.10.134-16.3.al8.x86_64
 Operating System: Alibaba Cloud Linux 3 (Soaring Falcon)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 3.499GiB
 Name: iZj6cdtkubp4jn6i3drnbzZ
 ID: 7196760b-fdec-4e69-8758-9186040c032c
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
[root@iZj ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:           3583         224        2582           2         776        3124
Swap:             0           0           0
[root@iZj~]# df -h
文件系统        容量  已用  可用 已用% 挂载点
devtmpfs        1.8G     0  1.8G    0% /dev
tmpfs           1.8G     0  1.8G    0% /dev/shm
tmpfs           1.8G  540K  1.8G    1% /run
tmpfs           1.8G     0  1.8G    0% /sys/fs/cgroup
/dev/vda3        79G   19G   57G   25% /
tmpfs           1.8G     0  1.8G    0% /tmp
/dev/vda2       200M  5.8M  195M    3% /boot/efi
tmpfs           359M     0  359M    0% /run/user/0

The vps is 2 cores, 4 gigs of ram.
I can’t rebuild it, it’s hooked up to cloudflare, and I’m trying to show the real ip.
Added - “templates/cloudflare.template.yml”
I can’t get it to rebuild.

According to your log, the failure was caused by the /tmp/add-cloudflare-ips step, but it’s unclear which specific command within this script failed.

Pups::ExecError: /tmp/add-cloudflare-ips failed with return #<Process::Status: pid 4229 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

Try removing the Cloudflare line from your app.yml, rebuild, then enter the container and manually execute the commands from templates/cloudflare.template.yml step by step, followed by nginx -s reload. In my experience, network issues causing wget to fail might be the cause.

run:
  - file:
      path: /tmp/add-cloudflare-ips
      chmod: +x
      contents: |
        #!/bin/bash -e
        # Download list of CloudFlare ips
        wget -q https://www.cloudflare.com/ips-v4/ -O - > /tmp/cloudflare-ips
        echo >> /tmp/cloudflare-ips
        wget -q https://www.cloudflare.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 &;/' | tr '\n' '\\\\' | sed 's/\\\\/\\\\n/g')

        echo CloudFlare IPs:
        echo $(echo | sed "/^/a $CONTENTS")
        # Insert into discourse.conf
        sed -i "/sendfile on;/a $CONTENTS\\n" /etc/nginx/conf.d/discourse.conf
        #sed -i "/sendfile on;/a $CONTENTS\\nreal_ip_header CF-Connecting-IP;" /etc/nginx/conf.d/discourse.conf
        # Clean up
        rm /tmp/cloudflare-ips

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

Does a VPS need swap? My VPS has a small amount of memory and doesn’t have swap by default.

The reason for your failure has nothing to do with memory/swap.

Also, others have encountered your problem before, so please search before asking. In fact, the Related section below has already intelligently recommended some for you, for example: Failed to bootstrap (/tmp/add-cloudflare-ips)