Trying to figure out why my Discourse instance isn’t working after running ./launcher rebuild app:

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && sudo -E -u discourse bundle exec rake s3:upload_assets failed with return #<Process::Status: pid 2475 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"cd"=>"$home", "cmd"=>["sudo -E -u discourse bundle exec rake s3:upload_assets", "sudo -E -u discourse bundle exec rake s3:expire_missing_assets"]}
bootstrap failed with exit code 1
** 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.
53b661a318ad0de6f1ea88f05b3e0b52bcd95560b4ca1c44f7f0a9bf255556f6

Earlier in the logs, I see:

I, [2024-09-21T18:46:41.038644 #1]  INFO -- : > cd /var/www/discourse && sudo -E -u discourse bundle exec rake s3:upload_assets
rake aborted!
Seahorse::Client::NetworkingError: SSL_connect returned=1 errno=0 peeraddr=149.137.141.9:443 state=error: certificate verify failed (hostname mismatch) (Seahorse::Client::NetworkingError)

I eventually find this thread, which says:

the actual hostname being connected to is bucketname.axhjdarc4cuy.compat.objectstorage.ap-singapore-1.oraclecloud.com, which does not match *.compat.objectstorage.ap-singapore-1.oraclecloud.com so the error is correct.

Although the thread is not about the same exact issue I’m running into, there is an important clue here. It took me a while to realize it, but it appears that Discourse is appending the bucket name to the URL at runtime. Sure enough, if I check my config, I can see that I have the bucket name in the S3 URL already:

DISCOURSE_S3_BUCKET: tsuki-discourse
DISCOURSE_S3_ENDPOINT: https://tsuki-discourse.s3.us-east-005.backblazeb2.com

So this means that Discourse is trying to connect to https://tsuki-discourse.tsuki-discourse.s3.us-east-005.backblazeb2.com, which is incorrect and would cause the certificate check to fail.

Changing DISCOURSE_S3_ENDPOINT to not have the bucket name fixes the issue:

DISCOURSE_S3_BUCKET: tsuki-discourse
DISCOURSE_S3_ENDPOINT: https://s3.us-east-005.backblazeb2.com