minio-js icon indicating copy to clipboard operation
minio-js copied to clipboard

Cannot access non-AWS endpoint that need to be accessed with virtual host

Open fileformat opened this issue 5 years ago • 4 comments

I'm trying to hit an non-AWS service (Aliyun) that requires virtual host style addressing. However, none of the settings seems to enable it. I'm doing this from node.js.

To make sure it isn't a problem in my code, I tried changing line 202 of minio.js to if (true) { to force virtual-host-style, and it worked.

So then I investigated why, and found the comment above isVirtualHostStyle in helpers.js does not match what the code does. My endpoint is https and does not have a period, but it is not an Amazon endpoint, so it will never use virtual host style.

I think there should be a ! in front of the isAmazonEndpoint call, but that seems like a change that will affect a lot of people, and that code has been there for 4 years, so I'm not sure how it is working for anyone else that needs virtual hosting.

Here is the trace result of a failing call (with minor redactions):

REQUEST: PUT /xxx/xxx.csv
host: oss-ap-southeast-5.aliyuncs.com
user-agent: MinIO (darwin; x64) minio-js/7.0.16
content-length: 1625
content-md5: syyc+k2zME50Z6PYGWtu6Q==
x-amz-date: 20200506T200917Z
x-amz-content-sha256: UNSIGNED-PAYLOAD
authorization: AWS4-HMAC-SHA256 Credential=xxx/20200506/dummy/s3/aws4_request, SignedHeaders=content-md5;host;x-amz-content-sha256;x-amz-date, Signature=**REDACTED**

RESPONSE: 403
server: AliyunOSS
date: Wed, 06 May 2020 20:09:19 GMT
content-type: application/xml
content-length: 263
connection: close
x-amz-request-id: 5EB3196FD06C7B353369627A

ERROR BODY:
{
	"code": "SecondLevelDomainForbidden",
	"requestid": "5EB3196FD06C7B353369627A",
	"hostid": "oss-ap-southeast-5.aliyuncs.com",
	"amzRequestid": null,
	"amzId2": null,
	"amzBucketRegion": null
}

The trace doesn't have the protocol, but I am setting useSSL: true, and checked that it definitely is https:.

I'm happy to submit a PR with the change if it will be accepted, or to do anything else so I can workaround the issue.

Thanks, Andrew

fileformat avatar May 06 '20 20:05 fileformat

@fileformat Please feel free to submit a PR. We welcome community contributions

kannappanr avatar May 07 '20 08:05 kannappanr

@kannappanr PR submitted!

fileformat avatar May 15 '20 19:05 fileformat

@kannappanr Any feedback on the PR? I'd like to get Minio working.

amarcuse avatar Jun 24 '20 13:06 amarcuse

@prakashsvmx Is this on target to be included in a release by March 31? Or should we expect this down the road?

aaronhuggins avatar Feb 11 '21 03:02 aaronhuggins