The s3 cdn url setting makes no effect

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.

Did you run the rake task to precompile assets and push to S3?
As described in
Set up file and image uploads to S3

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.

You can run the rake task without rebuilding like this:

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

Thank you very much!

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

What cdn are you using?

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:

  ## 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

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?

Thanks for your patience!

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

1 Like

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

Thanks again!

1 Like