-
-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for cname buckets #61
Conversation
Fog::Logger.warning("fog: the specified s3 bucket name(#{bucket_name}) contains a '.' so is not accessible over https as a virtual hosted bucket, which will negatively impact performance. For details see: http://docs.amazonwebservices.com/AmazonS3/latest/dev/BucketRestrictions.html") | ||
path_style = true | ||
if params[:bucket_cname] | ||
host = bucket_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't expect bucket_name to be a full host value, but rather just the name of the particular bucket. Does that not match up with you experience/expectation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geemus I'm using a bucket_name such as: assets.example.com
. As per this S3 documentation page, you can then have functioning urls in the form of: https://assets.example.com/the/path/to.png
I have only been able to get an url in that form by using this patch and passing in this option, but glad to be shown other ways of achieving this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. I think maybe you can do it via setting assets
as the bucket_name and example.com
as the host, but I'm not very certain of that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would entail defining the bucket_name as assets
on S3, and then the CNAME redirect wouldn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bah, sorry. I think maybe I'm just totally mis-remembering. Have you tried using the endpoint
param? I think maybe setting that to your CNAME might be the right thing. Sorry for the run around here, it's been ages since I interacted with this directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I've tried setting the endpoint
param and it seems a step in the right direction, but then I get an url like https://assets.example.com/assets.example.com/the/path/to.png
because of https://github.com/fog/fog-aws/blob/master/lib/fog/aws/storage.rb#L271. Also setting :path_style
to false
doesn't help, as a) it's re-set to true
in line 268; and b) even if it weren't, it means that https://github.com/fog/fog-aws/blob/master/lib/fog/aws/storage.rb#L273 would be run instead, and I would get an url like https://assets.example.com.assets.example.com/the/path/to.png
(which results in an excon exception since that domain is not an S3 domain)
Sorry for the delay, thanks! |
Ported from fog/fog#3140.
This allows users to pass
bucket_cname: true
and have the url be generated as per http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html#VirtualHostingCustomURLsIf this is missing tests, documentation, please let me know where and how it should be done. I couldn't find out much from the contributing guidelines. Thanks