# Unable to setup S3 bucket

**URL:** <https://meta.discourse.org/t/unable-to-setup-s3-bucket/346372>\
**Category:** Self-hosting\
**Tags:** uploads, s3\
**Created:** [January 9, 2025, 4:38pm UTC](https://meta.discourse.org/t/unable-to-setup-s3-bucket/346372 "2025-01-09T16:38:01Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![luigi7up](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/luigi7up/32/477213_2.png) [@luigi7up](https://meta.discourse.org/u/luigi7up)\
**Post date:** [January 12, 2025, 1:38pm UTC](https://meta.discourse.org/t/unable-to-setup-s3-bucket/346372/12 "2025-01-12T13:38:38Z")

</div>

Hi again, everyone,

I wanted to follow up on my previous post and share that I’ve made some progress.

**What’s working now**

- **User uploads** are correctly served from my S3 bucket through the CDN (CloudFront), so that’s great!

**However, I’m still facing an issue with the precompiled assets**

The precompiled assets are still not being served correctly from the CDN

When I set the DISCOURSE\_CDN\_URL to the CloudFront URL (i.e., [https://dsuqioxhrz2qn.cloudfront.net](https://dsuqioxhrz2qn.cloudfront.net)), the precompiled assets URLs become:

```
•	https://dsuqioxhrz2qn.cloudfront.net/stylesheets/color_definitions_shades-of-blue_7_1_e6f11758f9c015d1e5ed9b08c437e9c5c267c932.css?__ws=forum.hobiguru.com
•	https://dsuqioxhrz2qn.cloudfront.net/stylesheets/discourse-presence_308d905aa5c03567866fec50e9a28d8721ab0463.css

```

The problem is that these paths don’t exist in my S3 bucket. The precompiled assets are uploaded under `/assets/*` folder in S3 (e.g., /assets/locales, /assets/plugins, /assets/scripts), but there’s no `/stylesheets/` folder and of course loading of those URLs are resulting in 403 forbidden.

If, however I change the `DISCOURSE_CDN_URL: https://forum.hobiguru.com` then my forum is working correctly, but the assets are now served from the server (e.g. [https://forum.hobiguru.com/](https://forum.hobiguru.com/)) and not from the CDN (e.g. `https://forum.hobiguru.com/stylesheets/admin_308d905aa5c03567866fec50e9a28d8721ab0463.css?__ws=forum.hobiguru.com`)

My current setup (for context) is:

app.yaml

```yaml
DISCOURSE_USE_S3: true
DISCOURSE_S3_REGION: eu-central-1
DISCOURSE_S3_ACCESS_KEY_ID: AKIA......LQMB
DISCOURSE_S3_SECRET_ACCESS_KEY: PaXQu7pKN.....fJNY
DISCOURSE_S3_CDN_URL: https://dsuqioxhrz2qn.cloudfront.net # Ensure CDN URL points to CloudFront
DISCOURSE_CDN_URL: https://forum.hobigur.com # NOTICE THIS!
DISCOURSE_S3_BUCKET: hobiguru-s3-bucket-eu

```

and the precompile hooks:

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

```

It seems that after precomiling the assets there get uploaded to S3 into a certain structure, but then when loaded throught the CDN the path to the objects are a bit off

---

_[View the full topic](https://meta.discourse.org/t/unable-to-setup-s3-bucket/346372)._
