简体   繁体   English

使用Amazon Route 53为S3存储桶设置CNAME

[英]Setting up a CNAME for an S3 bucket using Amazon Route 53

I need the following url 我需要以下网址

http://liangpai.s3.amazonaws.com/uploadImage/shareImage/2012-10/506dc1ef71dcf.png http://liangpai.s3.amazonaws.com/uploadImage/shareImage/2012-10/506dc1ef71dcf.png

showing as: 显示为:

http://imgs.liangpai.me/uploadImage/shareImage/2012-10/506dc1ef71dcf.png http://imgs.liangpai.me/uploadImage/shareImage/2012-10/506dc1ef71dcf.png

My S3 bucket name is “liangpai”. 我的S3名称是“liangpai”。 On Route 53, I created a new CNAME named “imgs”, the value I entered is “liangpai.s3.amazonaws.com” 在Route 53上,我创建了一个名为“imgs”的新CNAME,我输入的值是“liangpai.s3.amazonaws.com”

After this I don't see the S3 web link changes to my domain link. 在此之后,我没有看到S3 web链接更改为我的域链接。

Anything wrong here? 这里有什么不对吗?

Thanks for your advice! 谢谢你的建议!

S3 CNAMEs require the bucket name to match the host name. S3 CNAME要求存储桶名称与主机名匹配。 If you want S3 to serve from imgs.langpai.me , you need to create a bucket named imgs.langpai.me . 如果您希望从imgs.langpai.me提供S3,则需要创建名为imgs.langpai.me的存储桶。 See the S3 documentation for more. 有关更多信息,请参阅S3文档

You could create a CloudFront distribution to answer to imgs.langpai.me (see CloudFront CNAME support ) have it and forward requests to langpai.s3.amazonaws.com . 您可以创建一个CloudFront分配来回答imgs.langpai.me (请参阅CloudFront CNAME支持 ),并将请求转发给langpai.s3.amazonaws.com This would, of course, also incur CloudFront charges. 当然,这也会产生CloudFront费用。

Method 1 : S3 direct CNAME by bucket name 方法1:S3按桶名称指示CNAME

You can create a CNAME record by bucket name following these steps. 您可以按照以下步骤按存储桶名称创建CNAME记录。

  1. Create a bucket name using the same name you will use for your dns entry. 使用与dns条目相同的名称创建存储桶名称。 ie subdomain.mydomain.net subdomain.mydomain.net

  2. Create a cname record for subdomain.mydomain.net to s3.amazonaws.com subdomain.mydomain.net创建一个cname记录到s3.amazonaws.com

  3. Set permissions on your bucket based on the access you plan to grant 根据您计划授予的访问权限设置存储桶的权限

Method 2 : Static Website on S3 方法2:S3上的静态网站

If you are serving static content such as images, files, etc. you can use "Static Website Hosting" for your S3 bucket . 如果您要提供静态内容(如图像,文件等),则可以使用“静态网站托管”作为S3存储桶

Select your bucket by clicking the bucket icon ( 通过单击桶图标选择您的桶( 在此输入图像描述 ) and select the "properties" tab on the right and expand "Static Website Hosting". )并选择右侧的“属性”选项卡,然后展开“静态网站托管”。 In the Static Website Hosting panel, select the radio button to "Enable website hosting" and set an index and error document. 在“静态网站托管”面板中,选择“启用网站托管”单选按钮并设置索引和错误文档。 It this point, you will see an "Endpoint" name in this panel. 在这一点上,您将在此面板中看到“端点”名称。 Simple create a DNS CNAME record with the endpoint as the value. 简单地创建DNS CNAME记录,并将端点作为值。 You can read the entire Amazon Walkthrough here. 您可以在此处阅读整个亚马逊演练

在此输入图像描述

Try this 尝试这个

Using your own bucket CNAME: 使用自己的存储桶CNAME:

echo S3::getAuthenticatedURL("s3bucket.mydomain.com", $uri, 3600, true);

but you putobject file check for read for Everyone premisssion type: 但是你把putobject文件检查为Everyone premisssion类型的读取:

S3::ACL_PUBLIC_READ S3 :: ACL_PUBLIC_READ

$s3-> putObjectFile ($tmp, $bucketname , $path.$filename, S3::ACL_PUBLIC_READ ) $ s3-> putObjectFile ($ tmp,$ bucketname,$ path。$ filename, S3 :: ACL_PUBLIC_READ

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

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