Skip to content
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

Merged
merged 1 commit into from
Mar 2, 2015
Merged

Conversation

dsgh
Copy link
Contributor

@dsgh dsgh commented Feb 24, 2015

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#VirtualHostingCustomURLs

If 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

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
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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)

@geemus
Copy link
Member

geemus commented Mar 2, 2015

Sorry for the delay, thanks!

geemus added a commit that referenced this pull request Mar 2, 2015
Add support for cname buckets
@geemus geemus merged commit d5ac067 into fog:master Mar 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants