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

Virtual host address support #92

Closed
Piedone opened this issue Apr 7, 2024 · 7 comments
Closed

Virtual host address support #92

Piedone opened this issue Apr 7, 2024 · 7 comments
Labels

Comments

@Piedone
Copy link

Piedone commented Apr 7, 2024

Do I understand correctly that LocalS3 doesn't support virtual-hosted–style buckets? See Virtual hosting of buckets. So, mybucket.localhost:8080 won't work, only localhost:8080/mybucket.

This is what I noticed: Using the official AWS .NET SDK, I'm string to check the existence of a bucket:

await AmazonS3Util.DoesS3BucketExistV2Async(myAmazonS3Client, "my-bucket")

This works with live S3 resources, but not with LocalS3, since it always returns true. This is what I see in the LocalS3 logs:

2024-04-07 02:06:27 2024-04-07 08:06:27.080 INFO  [main] com.robothy.s3.docker.App:25 - Starting LocalS3 in IN_MEMORY mode.
2024-04-07 02:06:27 2024-04-07 08:06:27.090 INFO  [main] com.robothy.s3.rest.LocalS3:109 - Created in-memory LocalS3 manager.
2024-04-07 02:06:27 2024-04-07 08:06:27.391 INFO  [main] com.robothy.s3.rest.LocalS3:100 - LocalS3 started.
2024-04-07 02:06:58 2024-04-07 08:06:58.396 INFO  [defaultEventLoopGroup-4-1] c.r.netty.codec.HttpMessageHandler:94 - Channel bc5f7998 active.
2024-04-07 02:06:58 2024-04-07 08:06:58.431 INFO  [defaultEventLoopGroup-4-1] c.r.netty.codec.HttpMessageHandler:70 - Rendered 200 to GET /?acl

From the last line it seems to me that the bucket name actually doesn't reach LocalS3 but it's empty. This is confirmed if I try to add a file to such a bucket, since I get:

2024-04-07 01:59:24 2024-04-07 07:59:24.241 INFO  [main] com.robothy.s3.docker.App:25 - Starting LocalS3 in IN_MEMORY mode.
2024-04-07 01:59:24 2024-04-07 07:59:24.251 INFO  [main] com.robothy.s3.rest.LocalS3:109 - Created in-memory LocalS3 manager.
2024-04-07 01:59:24 2024-04-07 07:59:24.565 INFO  [main] com.robothy.s3.rest.LocalS3:100 - LocalS3 started.
2024-04-07 01:59:34 2024-04-07 07:59:34.115 INFO  [defaultEventLoopGroup-4-1] c.r.netty.codec.HttpMessageHandler:94 - Channel e8235084 active.
2024-04-07 01:59:34 2024-04-07 07:59:34.154 INFO  [defaultEventLoopGroup-4-1] c.r.netty.codec.HttpMessageHandler:70 - Rendered 200 to GET /?acl
2024-04-07 02:00:20 2024-04-07 08:00:20.925 ERROR [defaultEventLoopGroup-4-1] c.r.netty.codec.HttpMessageHandler:48 - Failed to handle PUT /
2024-04-07 02:00:20 com.robothy.s3.core.exception.InvalidBucketNameException: The bucket name '' is invalid.
2024-04-07 02:00:20     at com.robothy.s3.core.asserionts.BucketAssertions.assertBucketNameIsValid(BucketAssertions.java:30)
2024-04-07 02:00:20     at com.robothy.s3.core.service.CreateBucketService.createBucket(CreateBucketService.java:31)
2024-04-07 02:00:20     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2024-04-07 02:00:20     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
2024-04-07 02:00:20     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2024-04-07 02:00:20     at java.base/java.lang.reflect.Method.invoke(Method.java:568)
2024-04-07 02:00:20     at com.robothy.s3.core.service.manager.LocalS3ServicesInvocationHandler.invoke(LocalS3ServicesInvocationHandler.java:38)
2024-04-07 02:00:20     at jdk.proxy2/jdk.proxy2.$Proxy14.createBucket(Unknown Source)
2024-04-07 02:00:20     at com.robothy.s3.rest.handler.CreateBucketController.handle(CreateBucketController.java:47)
2024-04-07 02:00:20     at com.robothy.netty.codec.HttpMessageHandler.channelRead0(HttpMessageHandler.java:46)
2024-04-07 02:00:20     at com.robothy.netty.codec.HttpMessageHandler.channelRead0(HttpMessageHandler.java:19)
2024-04-07 02:00:20     at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99)
2024-04-07 02:00:20     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
2024-04-07 02:00:20     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
2024-04-07 02:00:20     at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
2024-04-07 02:00:20     at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
2024-04-07 02:00:20     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
2024-04-07 02:00:20     at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:61)
2024-04-07 02:00:20     at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:425)
2024-04-07 02:00:20     at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
2024-04-07 02:00:20     at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54)
2024-04-07 02:00:20     at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
2024-04-07 02:00:20     at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
2024-04-07 02:00:20     at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
2024-04-07 02:00:20     at java.base/java.lang.Thread.run(Thread.java:833)

Thank you!

@Robothy Robothy added the feature label Apr 7, 2024
@Piedone
Copy link
Author

Piedone commented Apr 7, 2024

BTW mapping the container to the subdomain, like below from a Windows hosts file, doesn't help:

127.0.0.1 bucketname.localhost

@Robothy
Copy link
Owner

Robothy commented Apr 9, 2024

@Piedone I think LocalS3 is able to support virtual host following the HTTP Host header bucket specification.

@Piedone
Copy link
Author

Piedone commented Apr 9, 2024

At least for me with the .NET SDK it doesn't seem to work (my code otherwise works with real S3 resources, as well as some other emulator). It seems to send the Host header correctly.

Are you saying that LocalS3 handles the Host header?

@Robothy
Copy link
Owner

Robothy commented Apr 10, 2024

LocalS3 will soon support virtual hosting, as your project requires this feature. The implementation will adhere to the HTTP Host header bucket specification and is expected to be published in the next few days.

@Piedone
Copy link
Author

Piedone commented Apr 10, 2024

Awesome, thank you!

@Robothy
Copy link
Owner

Robothy commented Apr 11, 2024

Version 1.15 supported virtual host address.

@Robothy Robothy closed this as completed Apr 11, 2024
@Piedone
Copy link
Author

Piedone commented Apr 11, 2024

Oh wow, awesome, thank you for being so quick!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants