サイトの s3/cdn 設定の修正を試みており、問題に直面しています。少し前の経緯を説明します。以前は Digital Ocean Spaces と Bunny.net を CDN として使用していました。サイト設定ではすべて適切に設定していましたが、動作原理や重要性を理解していなかったため、app.yml 内に DISCOURSE_CDN_URL を設定していませんでした。最近、DO Spaces で問題が発生したため Amazon S3 に切り替えましたが、CDN は Bunny.net のままにしました。この切り替えの部分は理解できたと思っていますし、@pfaffman さんがデータベースのマッピングを助けてくれる予定です。
現在の問題は DISCOURSE_CDN_URL の設定にあります。Bunny に新しいプルゾーンを作成し、オリジン URL を私のフォーラムである https://community.naturephotographers.network に設定しました。これに対応する CNAME を assets.naturephotographers.network に設定し、DISCOURSE_CDN_URL を https://assets.naturephotographers.network に設定しました。再構築は正常に行われますが、サイトのアセットが assets.naturephotographers.network の CDN から読み込まれず、何らかの理由で Amazon バケットから読み込まれてしまいます。
以下の rake タスクを実行しようとしました。
after_assets_precompile:
- exec:
cd: $home
cmd:
- sudo -E -u discourse bundle exec rake s3:upload_assets
しかし、以下のエラーで失敗しました。
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 のサイト設定です。
別の興味深い点として、s3/cdn の設定をサイト設定ではなく app.yml にすべて記述すると、サイトが破損し、設定が完全に同じであるにもかかわらず白いページしか表示されず、コンソールには多数の 403 エラーが発生します。
## 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
何かご存知でしょうか?よろしくお願いいたします!
