# The s3 cdn url setting makes no effect

**URL:** https://meta.discourse.org/t/the-s3-cdn-url-setting-makes-no-effect/245078
**Category:** Self-hosting
**Tags:** s3
**Created:** [November 10, 2022, 3:40am UTC](https://meta.discourse.org/t/the-s3-cdn-url-setting-makes-no-effect/245078 "2022-11-10T03:40:47Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![shaoyaoqian](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shaoyaoqian/32/281252_2.png) [@shaoyaoqian](https://meta.discourse.org/u/shaoyaoqian)
#### Post date: [November 10, 2022, 3:40am UTC](https://meta.discourse.org/t/the-s3-cdn-url-setting-makes-no-effect/245078/1 "2022-11-10T03:40:47Z")

</div>

Hi everyone!

The s3 cdn url setting works well for photos but it makes no effect for other kinds of files. It appears that the s3 cdn url was replaced by the endpoint url for uploaded files.

for example, my s3 cdn url is `http://qiniu.pengfeima.cn`, my s3 endpoint url is `http://qiniu-s3.s3-ap-southeast-1.qiniucs.com`. When I click the short url on discourse, it links to  
`http://qiniu-s3.s3-ap-southeast-1.qiniucs.com/original/2X/e/effbf521dc7f117e7d9b57ed41b2cac576bf39d5.txt`, but the correct url should use cdn url rather than endpoint url.

How can I solve this problem?

> PS  
> On my site, S3 parameters were set on the panels, not in the app.yml.

---

<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: [November 10, 2022, 11:59am UTC](https://meta.discourse.org/t/the-s3-cdn-url-setting-makes-no-effect/245078/2 "2022-11-10T11:59:21Z")

</div>

Did you run the rake task to precompile assets and push to S3?  
As described in  
[Set up file and image uploads to S3](https://meta.discourse.org/t/set-up-file-and-image-uploads-to-s3/7229)

---

<div class="post-metadata">

### Author: ![shaoyaoqian](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shaoyaoqian/32/281252_2.png) [@shaoyaoqian](https://meta.discourse.org/u/shaoyaoqian)
#### Post date: [November 10, 2022, 12:52pm UTC](https://meta.discourse.org/t/the-s3-cdn-url-setting-makes-no-effect/245078/3 "2022-11-10T12:52:00Z")

</div>

I have configured relevant settings on admin panel, but I need to modify the app.yml and then rebuild app? I know how to do it but it seems risky.

---

<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: [November 10, 2022, 4:29pm UTC](https://meta.discourse.org/t/the-s3-cdn-url-setting-makes-no-effect/245078/4 "2022-11-10T16:29:31Z")

</div>

You can run the rake task without rebuilding like this:

```plaintext
./launcher enter app
rake assets:precompile rake s3:upload_assets

```

---

<div class="post-metadata">

### Author: ![shaoyaoqian](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shaoyaoqian/32/281252_2.png) [@shaoyaoqian](https://meta.discourse.org/u/shaoyaoqian)
#### Post date: [November 10, 2022, 5:42pm UTC](https://meta.discourse.org/t/the-s3-cdn-url-setting-makes-no-effect/245078/5 "2022-11-10T17:42:44Z")

</div>

Thank you very much!

I did as you said, but my website has broken. The uploaded assets are \*.gz.js which have encoding problems.

 ![image](https://global.discourse-cdn.com/meta/original/4X/1/5/a/15a4cdc575e925f069137a72040e9c1fe3992e7a.png)

 ![image](https://global.discourse-cdn.com/meta/original/4X/8/b/7/8b7b16a8417e1eec5f2b511d92e4499f29e54c26.png)

---

<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: [November 10, 2022, 6:25pm UTC](https://meta.discourse.org/t/the-s3-cdn-url-setting-makes-no-effect/245078/6 "2022-11-10T18:25:07Z")

</div>

What cdn are you using?

---

<div class="post-metadata">

### Author: ![shaoyaoqian](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shaoyaoqian/32/281252_2.png) [@shaoyaoqian](https://meta.discourse.org/u/shaoyaoqian)
#### Post date: [November 10, 2022, 6:42pm UTC](https://meta.discourse.org/t/the-s3-cdn-url-setting-makes-no-effect/245078/7 "2022-11-10T18:42:14Z")

</div>

It is called qiniu which is a Chinese cloud service provider.  
`https://www.qiniu.com`

The problem is caused by cdn?

here is my setting:

```plaintext
  ## S3 storage
  DISCOURSE_USE_S3: true
  DISCOURSE_S3_REGION: whatever
  DISCOURSE_S3_ENDPOINT: http://s3-ap-southeast-1.qiniucs.com
  DISCOURSE_S3_ACCESS_KEY_ID: *************
  DISCOURSE_S3_SECRET_ACCESS_KEY: *****************
  DISCOURSE_S3_CDN_URL: http://qiniu.pengfeima.cn
  DISCOURSE_S3_BUCKET: qiniu-s3
  DISCOURSE_S3_BACKUP_BUCKET: qiniu-s3/backups
  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: [November 10, 2022, 7:12pm UTC](https://meta.discourse.org/t/the-s3-cdn-url-setting-makes-no-effect/245078/8 "2022-11-10T19:12:26Z")

</div>

Do you get the same file with the same headers if you use the CDN as you do when you get the asset directly from the bucket?

---

<div class="post-metadata">

### Author: ![shaoyaoqian](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shaoyaoqian/32/281252_2.png) [@shaoyaoqian](https://meta.discourse.org/u/shaoyaoqian)
#### Post date: [November 10, 2022, 7:21pm UTC](https://meta.discourse.org/t/the-s3-cdn-url-setting-makes-no-effect/245078/9 "2022-11-10T19:21:15Z")

</div>

Thanks for your patience!

I can download the file directly with such link [http://qiniu.pengfeima.cn/assets/discourse-6a8036cdae750c5b30dadebc5bb6f5f3d3c205f173e19757ab47eb6314c9d8ec.gz.js](http://qiniu.pengfeima.cn/assets/discourse-6a8036cdae750c5b30dadebc5bb6f5f3d3c205f173e19757ab47eb6314c9d8ec.gz.js). It is the same file used in the browser, which is downloaded with cdn.

---

<div class="post-metadata">

### Author: ![shaoyaoqian](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shaoyaoqian/32/281252_2.png) [@shaoyaoqian](https://meta.discourse.org/u/shaoyaoqian)
#### Post date: [November 11, 2022, 2:51am UTC](https://meta.discourse.org/t/the-s3-cdn-url-setting-makes-no-effect/245078/10 "2022-11-11T02:51:49Z")

</div>

I think there is some problems during upload assets(only photos are correct). I won’t use cdn for assets anymore.

Thanks again!
