I have faced with the following problem: I use aws s3 as media storage. Since some moment aws was made path-style urls (e.g. http://s3.aws.com/bucket-name/object-key) deprecated and now the correct way to build urls is to use virtual-host-style urls (e.g. http://bucket-name.s3.aws.com/object-key).
For deployments (prod, stage, etc.) it sounds good to use virtual-host-style approach. But it seems that MinIO does not provide some suitable solution to use virtual-host-style for local dev.
I use docker-compose file to setup local infrastructure. Here is my compose file:
services:
minio:
container_name: "minio"
image: minio/minio:RELEASE.2025-03-12T18-04-18Z
ports:
- "9000:9000"
- "9001:9001"
environment:
- MINIO_ROOT_USER=user
- MINIO_ROOT_PASSWORD=1234678
command: server /data --console-address ":9001"
I use dotnet:
private static void AddAmazonS3(this IServiceCollection services)
{
var options = new AmazonS3Config
{
UseHttp = true,
ServiceURL = "http://localhost:9000",
};
services.AddSingleton<IAmazonS3>(_ => new AmazonS3Client("user", "12346578", options));
}
I have configured hosts file to resolve routing, but it still not working:
127.0.0.1 bucket-name.localhost
I have created bucket with the correct name and once I have tried to upload a file I got the error: Amazon.S3.AmazonS3Exception: The specified bucket does not exist
It seems that minio does not support virtual-host-style.