Redirect / route s3 bucket to domain

≯℡__Kan透↙ 提交于 2020-06-29 12:24:46

问题


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


回答1:


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)


来源:https://stackoverflow.com/questions/42108491/redirect-route-s3-bucket-to-domain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!