Reputation: 36034
Currently, I have an S3 bucket set up that has URL:
https://s3-us-west-2.amazonaws.com/<BucketName>/<Filename>
What I would like to do is to load the files from this bucket from:
https://images.mysite.com/<Filename>
This AWS documentation page says:
The bucket name must be the same as the 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.
Does this mean that I have to rename my bucket?
If I was to rename the bucket, do I first need to "enable website hosting" in order to rename it?
If I was to rename my bucket, what happens to the files that were referenced with previous bucket name?
Upvotes: 0
Views: 410
Reputation: 1208
If you do not want to change the bucket name then you need to proxy the resource either through Amazon Cloudfront (which will require cache invalidation when you make changes to your bucket content) or you could spin up a small EC2 instance with an Apache Web Proxy
ServerName yourdomain.com
<Proxy *>
Order allow,deny
Allow from all
SetEnv proxy-chain-auth
</Proxy>
SSLProxyEngine On
ProxyRequests On
ProxyPreserveHost Off
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
ProxyPass / http://your-bucket.s3-website-us-west-2.amazonaws.com/
ProxyPassReverse / http://your-bucket.s3-website-us-west-2.amazonaws.com/
Note the ProxyPreserveHost Off directive, which means the s3 name is still delivered to the target. Disadvantage to Apache proxy is that it becomes a bottleneck, but you can use t2.smalls in the free tier and then add them to an autoscale group
Upvotes: 0
Reputation: 46839
If you don't actually want to run a website from your s3 bucket, but instead are just looking to serve images with a custom domain (which it seems like from your question), then you could use a custom domain with cloudfront distribution and you won't have to move or rename anything (and the old links will continue to still work):
http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html
Answers to your questions though:
Upvotes: 1