将s3存储桶重定向/路由到域 [英] Redirect / route s3 bucket to domain
问题描述
我正在寻找将所有s3存储桶链接重定向/路由到域或将域链接到s3存储桶的最佳方法.
我正在从专用主机迁移到AWS,并使用s3存储桶来存储文件.
示例: http://www.example.com.au/app - >指向 http://examplebucket.s3.amazonaws.com/app
但是我有很多它们以及指向域/文件的混合应用程序,所以不确定是否有办法在AWS控制台或php脚本中实现路由?
谢谢
如果存储桶的名称与域名相同,则可以将自定义域名指向Amazon S3存储桶./p>
因此,如果您拥有域名example.com
,则可以按照以下步骤将www.example.com
指向名为www.example.com
的存储桶:
- 创建具有匹配名称的存储桶
- 打开静态网站托管并复制显示的URL
- 为
www.example.com
创建Route 53记录集,将其指向先前复制的URL
请参阅文档:设置使用自定义域的静态网站
更新:正如sqlbot指出的,另一种选择是在Amazon S3之前使用Amazon CloudFront.这有几个好处:
- 存储桶名称不需要与域名匹配
- 域名可以指向多个不同的来源(例如,
/images
可能来自一个存储桶,而/css
可能来自另一个存储桶) - 它支持
HTTPS
(在直接转到Amazon S3时无法实现,因为URL解析为通用S3 IP地址)
Hi I am looking for the best way to redirect / route all s3 bucket links to a domain or link domain to s3 bucket.
I am migrating from dedicated hosting to aws and using s3 bucket to store files.
Example: http://www.example.com.au/app --> directs to http://examplebucket.s3.amazonaws.com/app
But i have heaps of them and hybrid apps that point to domain/files so not sure if theres a way to route within aws console or php script to achieve?
Thanks
You can point a custom domain name to an Amazon S3 bucket, if the bucket is named the same as the domain name.
So, if you own the domain name example.com
, you can point www.example.com
to a bucket called www.example.com
with these steps:
- Create the bucket with the matching name
- Turn on Static Website hosting and copy the displayed URL
- Create a Route 53 Record Set for
www.example.com
point it to the URL copied earlier
See documentation: Setting Up a Static Website Using a Custom Domain
Update: As pointed out by sqlbot, another option is to use Amazon CloudFront in front of Amazon S3. This has several benefits:
- The bucket name does not need to match the domain name
- The domain name can point to several different origins (eg
/images
could come from one bucket and/css
could come from another) - It supports
HTTPS
(which is not possible when going direct to Amazon S3 because the URL resolves to a generic S3 IP address)
这篇关于将s3存储桶重定向/路由到域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!