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

handle s3rver launched with ip other than localhost #421

Merged
merged 3 commits into from
Mar 25, 2019

Conversation

allan-simon
Copy link
Contributor

(for example docker environment), now we don't only test for ctx.hostname being 127.0.0.1, but any ip
other when using docker, you would end up with an ip in for example 172.12.0.6, and vhost.js would
have erroneously replaced ctx.path by /undefined/$bucketname

(for example docker environment), now we don't only test for ctx.hostname being 127.0.0.1, but any ip
other when using docker, you would end up with an ip in for example 172.12.0.6, and vhost.js would
have erroneously replaced ctx.path by  `/undefined/$bucketname`
@@ -15,7 +17,7 @@ module.exports = () =>
if (bucket) {
ctx.path = `/${bucket}${ctx.path}`;
}
} else if (ctx.hostname !== "localhost" && ctx.hostname !== "127.0.0.1") {
} else if (ctx.hostname !== "localhost" && !net.isIP(ctx.hostname)) {
// otherwise attempt to distinguish virtual host-style requests
ctx.path = `/${bucket}${ctx.path}`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! Though this doesn't totally fix the underlying issue. I believe this line should also read

  ctx.path = `/${ctx.hostname}${ctx.path}`

Regarding tests, I'm realizing the existing test should be named should reach the server with a bucket vhost subdomain. The behavior fixed in this PR should probably add a couple tests for vhost-style and IP-style requests.

@kherock
Copy link
Collaborator

kherock commented Mar 25, 2019

I was worried my description of the testing suite fixes needed might not have been too clear, so I went ahead and made the changes myself. Again, thanks for pointing this out!

@kherock kherock merged commit 7952ae7 into jamhall:master Mar 25, 2019
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