-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
How to set S3 vhost? #347
Comments
You should be able to create a client that has a custom base_url and a region set to the appropriate region in which the CNAME bucket points to (e.g., if you created a bucket in us-west-1, then your region should be us-west-1).
How is it failing? |
I'm passing the 'base_url' to the Trying to set the key to test, and the base_url to http://s3.yourdomain.com without a bucket I get: [curl] 6: Could not resolve host: test [url] http://test |
What did you pass as the
Can you show your code? What operation are you sending? |
I'm also having a bit of trouble with this. I've set the base_url parameter like so:
However, when I call Am I misunderstanding how this feature works? |
Sorry for the delay I think what I was testing with was something like this. I tried with and without a bucket name since I think it is supposed to be passed through the CNAME. $client = \S3Client::factory(
'key' => $aws_key,
'secret' => $aws_secret,
'base_url' => 'http://s3.example.com',
);
$url = $client->getObjectUrl('', 'test');
echo $url; |
Per the conversation on Gitter with @jeremeamia it was explained that changing the getObjectUrl call to the following fixed this issue: $client = S3Client::factory(
'key' => $key,
'secret' => $secret,
'base_url' => 'http://s3.example.com/my-bucket/',
);
$url = $client->getObjectUrl('my-bucket', 'file.txt', null, ['PathStyle' => true]) So the url would now resolve as: |
That is almost right. You should set the The |
This workaround does allow me to use getObjectUrl correctly, but the upload feature won't work till I applies another trick posted also by @jeremeamia Hopefully this will help someone saves hours of fiddling with the code. |
Unfortunately I celebrated too early. It seems like by setting host I generate another error: "The request signature we calculated does not match the signature you provided. Check your key and signing method." |
In a previous PHP SDK for S3 there was a way to set the virtual host so if you had a CNAME of
s3.yourdomain.com
and it was pointed tos3.amazonaws.com.
you could set the vhost option and itgetObjectUrl
calls would use the correct URL.It appears to have worked by setting region to null and setting the base_url to say
http://s3.yourdomain.com
, but I'm having trouble getting that to work either.http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html
Do you know how to set this in the current SDK?
The text was updated successfully, but these errors were encountered: