diff --git a/conf/config.default.toml b/conf/config.default.toml index 5c8e671..1e09f3b 100644 --- a/conf/config.default.toml +++ b/conf/config.default.toml @@ -14,6 +14,9 @@ type = 'fs' [storage.fs] root = './data' +[storage.s3] +bucket-lookup = "auto" + [limits] max-site-size = '128MB' max-manifest-size = '1MB' diff --git a/conf/config.example.toml b/conf/config.example.toml index 83c4459..018a3d3 100644 --- a/conf/config.example.toml +++ b/conf/config.example.toml @@ -30,6 +30,7 @@ root = "./data" [storage.s3] # non-default section endpoint = "play.min.io" +bucket-lookup = "auto" access-key-id = "Q3AM3UQ867SPQQA43P2F" secret-access-key = "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG" region = "us-east-1" diff --git a/src/backend_s3.go b/src/backend_s3.go index 867f7e2..fa929b7 100644 --- a/src/backend_s3.go +++ b/src/backend_s3.go @@ -155,13 +155,27 @@ func makeCacheOptions[K comparable, V any]( } func NewS3Backend(ctx context.Context, config *S3Config) (*S3Backend, error) { + var bucketLookup minio.BucketLookupType + + switch config.BucketLookup { + case "auto": + bucketLookup = minio.BucketLookupAuto + case "path": + bucketLookup = minio.BucketLookupPath + case "dns": + bucketLookup = minio.BucketLookupDNS + default: + return nil, fmt.Errorf("unknown bucket lookup type: %s", config.BucketLookup) + } + client, err := minio.New(config.Endpoint, &minio.Options{ Creds: credentials.NewStaticV4( config.AccessKeyID, config.SecretAccessKey, "", ), - Secure: !config.Insecure, + Secure: !config.Insecure, + BucketLookup: bucketLookup, }) if err != nil { return nil, err diff --git a/src/config.go b/src/config.go index 4227cb1..c446f50 100644 --- a/src/config.go +++ b/src/config.go @@ -112,6 +112,7 @@ type FSConfig struct { type S3Config struct { Endpoint string `toml:"endpoint"` Insecure bool `toml:"insecure"` + BucketLookup string `toml:"bucket-lookup" default:"auto"` AccessKeyID string `toml:"access-key-id"` SecretAccessKey string `toml:"secret-access-key"` Region string `toml:"region"`