简体   繁体   English

使用Cloudfront从S3提供图像

[英]Serving images from S3 using Cloudfront

I have an S3 bucket where images are uploaded to. 我有一个S3桶,上传图像。 All of my static content is served via a Cloudfront distribution however, or at least it should be. 我的所有静态内容都是通过Cloudfront发行版提供的,或者至少应该是。

When I look at my page source, it indicates that all static content, except for the images in my S3 bucket, is served from Cloudfront. 当我查看我的页面源时,它表示除了我的S3存储桶中的图像之外的所有静态内容都是从Cloudfront提供的。 The images in S3 is still served from S3. S3中的图像仍由S3提供。

I have played around with my settings, but nothing seems to be fixing this issue. 我玩过我的设置,但似乎没有什么能解决这个问题。

Currently in my Cloudfront distribution I have the following settings: 目前在我的Cloudfront发行版中,我有以下设置:

  1. Origin Pointing to my web url (foo.herokuapp.com) Origin指向我的网址(foo.herokuapp.com)
  2. Origin Pointing to my S3 Bucket: Origin指向我的S3 Bucket:

    -Origin Domain name pointed to my S3 Bucket -Origin域名指向我的S3 Bucket

    • Origin Path pointed to /uploads (This is the base directory in my S3 Bucket) Origin Path指向/ uploads(这是我的S3 Bucket中的基本目录)
    • Restrict Bucket Access set to Yes 限制Bucket Access设置为Yes
    • Tried setting Origin Access Identity to Create new and Setting Update Bucket policy to yes. 尝试将Origin Access Identity设置为创建新策略并将Update Bucket策略设置为yes。 I checked my Bucket Policy and it has created a Cloudfront Entry in there. 我检查了我的Bucket Policy并在那里创建了一个Cloudfront Entry。

Any idea on what might cause this setup not to retrieve my S3 content via Cloudfront? 有什么可能导致此设置不通过Cloudfront检索我的S3内容的任何想法?

When I look at my page source 当我查看我的页面源代码时

Nothing in the S3 or Cloudfront settings is going to rewrite your pages and change the links there. S3或Cloudfront设置中的任何内容都不会重写您的页面并更改其中的链接。

Your code, your web framework, whatever is actually generating your pages needs to be configured to use Cloudfront instead of S3 when building the pages. 您的代码,Web框架,实际生成页面的任何内容都需要配置为在构建页面时使用Cloudfront而不是S3。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM