简体   繁体   English

CNAME到s3斗亚马逊

[英]CNAME to s3 bucket amazon

I would like to use a subdomain instead of the direct url to my s3 bucket at amazon.com. 我想在amazon.com上使用子域而不是直接url到我的s3桶。 So instead of downloading images via an url like http://bucket-images.s3-eu-west-1.amazonaws.com/path/to/image.png I would like to use http://assets.domain.com/path/to/image.png . 所以不要通过像http://bucket-images.s3-eu-west-1.amazonaws.com/path/to/image.png这样的网址下载图片,而是想使用http://assets.domain.com/path/to/image.png I tried setting a CNAME like this: 我尝试像这样设置一个CNAME:

CNAME   assets   domain.com    bucket-images.s3-eu-west-1.amazonaws.com

But after setting this CNAME I receive such error from amazon, when I visit the domain: 但在设置此CNAME后,当我访问域时,我从亚马逊收到此类错误:

<Error>
    <Code>NoSuchBucket</Code>
    <Message>The specified bucket does not exist</Message>
    <BucketName>assets.domain.com</BucketName>
    <RequestId>45646DFSDFSFASDF</RequestId>
    <HostId>
        dfasdcvcvd546456454ds5fasdf4ad5f64asdfasdfccdfgvggtg
    </HostId>
</Error>

Over here they're telling to change the bucketname: https://forums.aws.amazon.com/message.jspa?messageID=237562 But that doesn't make sense. 在这里,他们告诉要更改桶名: https ://forums.aws.amazon.com/message.jspa messageID = 237562但这没有意义。 I worked on a project earlier, who used a bucketname totally different from the subdomain. 我之前曾参与过一个项目,他使用了一个与子域完全不同的桶名。 So there has to be a way... Anyone who can help me out? 所以必须有办法...任何可以帮助我的人?

For S3 you need the CNAME and bucket name to match: 对于S3,您需要匹配CNAME和存储桶名称:

The bucket name must be the same as the CNAME. 存储桶名称必须与CNAME相同。 So http://images.johnsmith.net/filename would be the same as http://images.johnsmith.net.s3.amazonaws.com/filename if a CNAME were created to map images.johnsmith.net to images.johnsmith.net.s3.amazonaws.com 因此,如果创建了一个CNAME来将images.johnsmith.net映射到images.johnsmith,那么http://images.johnsmith.net/filename将与http://images.johnsmith.net.s3.amazonaws.com/filename相同。 .net.s3.amazonaws.com

So in your specific example you need to name the bucket assets.domain.com . 因此,在您的特定示例中,您需要将存储桶assets.domain.com命名为assets.domain.com

http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html#VirtualHostingCustomURLs http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html#VirtualHostingCustomURLs

If you need more flexibility, you can create a CloudFront distribution for your S3 bucket and assign a CNAME to your CloudFront distribution. 如果您需要更大的灵活性,可以为S3存储桶创建CloudFront分配,并为您的CloudFront分配分配CNAME。

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html

Addtional to @Samuel Neff's information: 添加到@Samuel Neff的信息:

Just remember to name your AWS S3 bucket same as your Cloudflare CNAME record. 只需记住将您的AWS S3存储桶命名为与Cloudflare CNAME记录相同的名称。 Otherwise it will not work. 否则它将无法工作。

Here I tried and worked for me: 在这里,我试着为我工作:

Converted https://s3-eu-west-2.amazonaws.com/cdn.domain.com to http://cdn.domain.com https://s3-eu-west-2.amazonaws.com/cdn.domain.com转换为http://cdn.domain.com

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

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