Possible Regression. Tunneling with ngrok stopped working in v3
MichaelKovalchuk opened this issue · 1 comments
We are using ngrok to tunnel local s3 server through the https.
In s3rver v2.2.5 everything worked great. We were able to receive the following output while browsing the root (https://address.eu.ngrok.io/ -> http://localhost:4569/):
<ListAllMyBucketsResult xmlns="http://doc.s3.amazonaws.com/2006-03-01">
<Owner>
<ID>123</ID>
<DisplayName>S3rver</DisplayName>
</Owner>
<Buckets />
</ListAllMyBucketsResult>
In s3rver v3.0.3+ the output for the same route is:
<Error>
<Code>NoSuchBucket</Code>
<Message>The specified bucket does not exist</Message>
<BucketName>address.eu.ngrok.io</BucketName>
</Error>
It assumes that the address address.eu.ngrok.io
is the bucket name.
Logs from koa-router:
Request to https://address.eu.ngrok.io/ in s3rver v2.2.5:
koa-router GET / +8ms
info: Fetched 3 buckets
info: GET / 200 5ms 615b
Request to https://address.eu.ngrok.io/ in s3rver v3.0.3+
koa-router GET /address.eu.ngrok.io/ +9ms
error: No bucket found for "address.eu.ngrok.io"
info: GET / 404 3ms -
This is by design, s3rver v3 implements the behavior of the To associate a hostname with an Amazon S3 bucket using CNAMEs section of the documentation.
I'll think about how to add an option to enable the old behavior. My initial thought is to let the service endpoint be a configurable option. Currently this value is hardcoded as a pattern matching hostnames similar to s3.amazonaws.com
in various places within code, but allowing that to be swapped for something else might interfere with static website vhost behavior.
Would it be a problem if I required that the hostname match how AWS has their S3 subdomains? E.g. it would be possible to configure S3rver like
s3rver = new S3rver({
…,
serviceEndpoint: 'address.eu.ngrok.io' // default: 'amazonaws.com'
})
and after configuring a corresponding DNS record, have a request to https://s3.address.eu.ngrok.io/ log
koa-router GET / +8ms
info: Fetched 3 buckets
info: GET / 200 5ms 615b
(and if you also add a record for the static website endpoint, have)
$ curl https://my-bucket.s3-website-us-east-1.address.eu.ngrok.io
<!DOCTYPE html>
<html>…</html>