부트스트랩 실패 (/tmp/add-cloudflare-ips)

안녕하세요!

리빌드를 시도할 때 다음과 같은 오류가 발생합니다:

FAILED
--------------------
Pups::ExecError: /tmp/add-cloudflare-ips failed with return #<Process::Status: pid 1484 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"
9fe8337bb7b8e64abb480bd2527551585759e48df340dc74bb84c67bdf1ee6b2
** 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에서 프록시(주황색 구름)를 활성화하고 비활성화해도 이 오류는 여전히 발생합니다. :frowning:

위쪽으로 스크롤하여 /tmp/add-cloudflare-ips 명령이 실패한 부분의 출력을 보여줄 수 있나요?

CSS 컴파일 완료: 2022-03-22 16:54:37 UTC
I, [2022-03-22T16:54:37.832057 #1]  INFO -- : MaxMindDB 다운로드 중...
JavaScript 압축 및 소스 맵 생성

I, [2022-03-22T16:54:37.874506 #1]  INFO -- : 파일 > /usr/local/bin/discourse  chmod: +x  chown:
I, [2022-03-22T16:54:37.880784 #1]  INFO -- : 파일 > /usr/local/bin/rails  chmod: +x  chown:
I, [2022-03-22T16:54:37.887872 #1]  INFO -- : 파일 > /usr/local/bin/rake  chmod: +x  chown:
I, [2022-03-22T16:54:37.894248 #1]  INFO -- : 파일 > /usr/local/bin/rbtrace  chmod: +x  chown:
I, [2022-03-22T16:54:37.900136 #1]  INFO -- : 파일 > /usr/local/bin/stackprof  chmod: +x  chown:
I, [2022-03-22T16:54:37.907873 #1]  INFO -- : 파일 > /etc/update-motd.d/10-web  chmod: +x  chown:
I, [2022-03-22T16:54:37.912825 #1]  INFO -- : 파일 > /etc/logrotate.d/rails  chmod:   chown:
I, [2022-03-22T16:54:37.917132 #1]  INFO -- : 파일 > /etc/logrotate.d/nginx  chmod:   chown:
I, [2022-03-22T16:54:37.924129 #1]  INFO -- : 파일 > /etc/runit/1.d/00-ensure-links  chmod: +x  chown:
I, [2022-03-22T16:54:37.930083 #1]  INFO -- : 파일 > /etc/runit/1.d/01-cleanup-web-pids  chmod: +x  chown:
I, [2022-03-22T16:54:37.936780 #1]  INFO -- : 파일 > /root/.bash_profile  chmod: 644  chown:
I, [2022-03-22T16:54:37.941664 #1]  INFO -- : 파일 > /usr/local/etc/ImageMagick-7/policy.xml  chmod:   chown:
I, [2022-03-22T16:54:37.949303 #1]  INFO -- : (?-mix:server.+{) 를 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 {
 로 교체하는 중 /etc/nginx/conf.d/discourse.conf
I, [2022-03-22T16:54:37.952599 #1]  INFO -- : (?-mix:location @discourse {) 를 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; 로 교체하는 중 /etc/nginx/conf.d/discourse.conf
I, [2022-03-22T16:54:37.960935 #1]  INFO -- : 파일 > /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/
www.cloudflare.com (www.cloudflare.com) 이름 해석 중... 104.16.124.96, 104.16.123.96, 2606:4700::6810:7c60, ...
www.cloudflare.com (www.cloudflare.com)|104.16.124.96|:443 연결 중... 연결됨.
HTTP 요청 전송, 응답 대기 중... 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 -- : 비동기 프로세스 종료
I, [2022-03-22T16:54:38.148916 #1]  INFO -- : 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 에 INT 전송
2022-03-22 16:54:38.149 UTC [42] LOG:  received fast shutdown request
I, [2022-03-22T16:54:38.150508 #1]  INFO -- : exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 103 에 TERM 전송
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 가 리턴 코드 #<Process::Status: pid 1487 exit 8> 로 실패함
실패 위치: /usr/local/lib/ruby/gems/2.7.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
파라미터 "/tmp/add-cloudflare-ips" 로 실행이 실패했습니다.
3123cbaef859e04ff382e3194e1745b88ee6e4777de9f0f7b45cb6cf2ac6d757
** 부트스트랩 실패(FAILED TO BOOTSTRAP) ** 이전의 오류 메시지를 확인하십시오. 오류가 여러 개일 수 있습니다.
./discourse-doctor 도구가 문제를 진단하는 데 도움이 될 수 있습니다.
root@app:/var/discourse#

Cloudflare가 IP 주소를 통해 IP 목록을 가져오는 것을 차단했습니다. 다시 시도하거나, 차단 사유를 문의하거나, 목록을 직접 관리할 수 있습니다.

즉각적인 문제를 해결하려면 로컬 컴퓨터에서 목록을 가져온 후 Cloudflare에서 가져오는 대신 템플릿에 하드코딩하도록 수정하고, Cloudflare 측에 연락하는 것이 좋습니다.

@RyanK 이 문제에 대해 어떤 조언이 있을까요? 저희 템플릿은 빌드할 때마다 목록을 가져오지만, 이는 문제가 되지 않아야 합니다. 만약 문제가 있다면 403 에러보다는 429 레이트 리밋 에러가 발생한다고 예상할 텐데요

질문해서 죄송합니다. 저는 전문가가 아니에요 :frowning: 템플릿 cloudflare.template.yml을 사용하지 않고 Cloudflare IP를 추가하는 방법은 무엇인가요? 저는 Ubuntu 20.04에서 Discourse Docker를 사용하고 있습니다.

저는 서로 다른 두 인스턴스에서, IP 주소도 다른 환경에서 동일한 문제를 겪고 있습니다. @GreenOWL 님은 어떤 DC(데이터센터)를 사용 중이신가요?

Cloudflare가 액세스를 차단하고 있고, 이를 수동으로 수정할 만큼 충분히 익숙하지 않다면 Cloudflare 프런팅을 제거하는 것을 강력히 권장합니다.

악성 사용자에게 지옥의 문을 열어주는 셈입니다.

호스팅 제공업체의 데이터 센터.

악용자를 끌어들이는 커뮤니티를 운영하지 않는 한 문제가 되지 않을 것입니다. 그리고 IP가 노출되지 않도록 Discourse를 구성하는 것은 꽤 까다롭습니다.

변형 2.

도움이 되지 않는다면 - 불만을 가진 사용자들을 멈추게 하세요.

사실 템플릿 액션은 다른 IP에서 CF IP를 가져와서 수동으로 임베드할 수 있습니다. @Falco 님이 좋은 조언을 해주셨네요.

네, Vultr도 마찬가지입니다. 모든 IP에서 발생하는 문제임을 명시하여 Vultr에 티켓을 제출하는 것이 좋겠습니다.

yaml 파일에서 마운트된 볼륨의 위치를 확인하세요.

cloudflare.template.yml에서 cloudflare.com/ips-v4/, cloudflare.com/ips-v6/ URL을 내 서버의 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 &;/' | 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
        # 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\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"

그 다음 앱 컨테이너가 원래 템플릿 대신 -static 템플릿을 사용하도록 변경하세요.

영구적으로 이 상태로 두지 마세요.

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-v4 및 https://www.cloudflare.com/ips-v6)의 미러를 생성해야 할 것 같습니다.