# Who can help me analyze why rebuilding is not possible when adding the cf real ip?

**URL:** <https://meta.discourse.org/t/cf-real-ip-rebuild/303509>\
**Category:** Self-hosting\
**Tags:** cdn\
**Created:** [April 12, 2024, 3:23am UTC](https://meta.discourse.org/t/cf-real-ip-rebuild/303509 "2024-04-12T03:23:00Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![fokx](https://avatars.discourse-cdn.com/v4/letter/f/958977/32.png) [@fokx](https://meta.discourse.org/u/fokx)\
**Post date:** [April 12, 2024, 8:29am UTC](https://meta.discourse.org/t/cf-real-ip-rebuild/303509/6 "2024-04-12T08:29:50Z")

</div>

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.

```plaintext
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.

```plaintext
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"

```

---

_[View the full topic](https://meta.discourse.org/t/cf-real-ip-rebuild/303509)._
