# DISCOURSE\_CDN\_URL 관련 도움 요청

**URL:** https://meta.discourse.org/t/help-with-discourse-cdn-url/198209
**Category:** Self-hosting
**Created:** [7월 26, 2021, 2:34오후 UTC](https://meta.discourse.org/t/help-with-discourse-cdn-url/198209 "2021-07-26T14:34:05Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![davidkingham](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/davidkingham/32/119528_2.png) [@davidkingham](https://meta.discourse.org/u/davidkingham)
#### Post date: [7월 26, 2021, 2:34오후 UTC](https://meta.discourse.org/t/help-with-discourse-cdn-url/198209/1 "2021-07-26T14:34:06Z")

</div>

사이트의 s3/cdn 설정을 수정하려다 문제가 발생했습니다. 간단한 배경 설명을 드리면, 저는 이전에 DigitalOcean Spaces를 S3 스토리지로, bunny.net를 CDN으로 사용했습니다. 사이트 설정에서 모든 항목을 올바르게 구성했지만, `DISCOURSE_CDN_URL`이 어떻게 작동하는지, 그리고 왜 중요한지 이해하지 못했기 때문에 app.yml에 설정한 적이 없었습니다. 최근 DO Spaces에서 문제가 발생하기 시작하자 Amazon S3로 전환하되, CDN은 여전히 bunny.net를 유지하고 있습니다. 전환 작업 중 이 부분은 해결한 것 같으며, @pfaffman 님이 데이터베이스 리매핑을 도와주실 예정입니다.

현재 겪고 있는 문제는 `DISCOURSE_CDN_URL` 설정과 관련이 있습니다. 저는 bunny에서 이를 위해 새로운 Pull Zone을 생성하고, Origin URL을 제 포럼 주소인 [https://community.naturephotographers.network로](https://community.naturephotographers.xn--network-vn12a) 설정했습니다. assets.naturephotographers.network로 가리키는 CNAME 레코드도 있습니다. 이후 `DISCOURSE_CDN_URL`을 [https://assets.naturephotographers.network로](https://assets.naturephotographers.xn--network-vn12a) 설정했는데, 빌드는 정상적으로 완료되지만 사이트의 에셋이 assets.naturephotographers.network의 CDN에서 가져와지지 않고, 알 수 없는 이유로 Amazon 버킷에서 로드되고 있습니다.

다음 rake 태스크를 실행해 보았지만,

```plaintext
  after_assets_precompile:
    - exec:
        cd: $home
        cmd:
          - sudo -E -u discourse bundle exec rake s3:upload_assets

```

아래와 같은 오류가 발생합니다:

```plaintext
I, [2021-07-26T13:31:31.754617 #1] INFO -- : > cd /var/www/discourse && sudo -E -u discourse bundle exec rake s3:upload_assets
`/root` is not writable.
Bundler will use `/tmp/bundler20210726-6572-1a099eq6572' as your home directory temporarily.
ERROR: Ensure S3 is configured in config/discourse.conf or environment vars
I, [2021-07-26T13:31:42.586559 #1] INFO -- :
I, [2021-07-26T13:31:42.587455 #1] INFO -- : Terminating async processes
I, [2021-07-26T13:31:42.587523 #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: 56
I, [2021-07-26T13:31:42.587764 #1] INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 173
173:signal-handler (2021-07-26 13:31:42.588 UTC [56] LOG: received fast shutdown request
1627306302) Received SIGTERM scheduling shutdown...
2021-07-26 13:31:42.594 UTC [56] LOG: aborting any active transactions
2021-07-26 13:31:42.596 UTC [56] LOG: background worker "logical replication launcher" (PID 65) exited with exit code 1
2021-07-26 13:31:42.599 UTC [6573] FATAL: terminating autovacuum process due to administrator command
2021-07-26 13:31:42.599 UTC [6573] CONTEXT: while vacuuming block 74749 of relation "pg_toast.pg_toast_21988"
2021-07-26 13:31:42.603 UTC [60] LOG: shutting down
173:M 26 Jul 2021 13:31:42.630 # User requested shutdown...
173:M 26 Jul 2021 13:31:42.630 * Saving the final RDB snapshot before exiting.
2021-07-26 13:31:42.766 UTC [56] LOG: database system is shut down
173:M 26 Jul 2021 13:31:43.123 * DB saved on disk
173:M 26 Jul 2021 13:31:43.123 # Redis is now ready to exit, bye bye...

```

제 s3/cdn 사이트 설정은 다음과 같습니다:

 ![CleanShot 2021-07-26 at 08.15.12@2x](https://global.discourse-cdn.com/meta/original/3X/e/9/e9734a717973ab3bf96d17d6a59534d59d31d33b.jpeg)

흥미로운 부가적인 사항으로, 사이트 설정 대신 app.yml에 s3/cdn 설정을 모두 넣으면 사이트가 깨져서 설정이 완전히 동일함에도 불구하고 흰색 화면만 표시되고 콘솔에 403 오류가 대량으로 발생합니다:

```plaintext
  ## S3 Configuration
  DISCOURSE_USE_S3: true
  DISCOURSE_S3_REGION: us-west-1
  DISCOURSE_S3_ACCESS_KEY_ID: ***
  DISCOURSE_S3_SECRET_ACCESS_KEY: ***
  DISCOURSE_S3_CDN_URL: https://images.naturephotographers.network
  DISCOURSE_S3_BUCKET: npnimages
  DISCOURSE_S3_BACKUP_BUCKET: npn-backup
  DISCOURSE_BACKUP_LOCATION: s3

```

어떤 아이디어라도 있을까요? 감사합니다!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [7월 26, 2021, 7:41오후 UTC](https://meta.discourse.org/t/help-with-discourse-cdn-url/198209/2 "2021-07-26T19:41:24Z")

</div>

> [@davidkingham](#):
>
> ```plaintext
> ERROR: Ensure S3 is configured in config/discourse.conf or environment vars
> 
> ```

환경 변수(ENV vars)에 반드시 설정해야 합니다. 데이터베이스에 설정해서는 작동하지 않습니다.
