From 43af46b48b5de1403759630f7c60e7e505a0c189 Mon Sep 17 00:00:00 2001 From: Xie Wu Date: Thu, 29 Aug 2024 21:24:54 +0800 Subject: [PATCH] Add IMGPROXY_S3_ENDPOINT_USE_PATH_STYLE control UsePathStyle (#1314) --- config/config.go | 3 +++ transport/s3/s3.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index c1dcf39a..1103de1b 100644 --- a/config/config.go +++ b/config/config.go @@ -107,6 +107,7 @@ var ( S3Enabled bool S3Region string S3Endpoint string + S3EndpointUsePathStyle bool S3AssumeRoleArn string S3AssumeRoleExternalID string S3MultiRegion bool @@ -308,6 +309,7 @@ func Reset() { S3Enabled = false S3Region = "" S3Endpoint = "" + S3EndpointUsePathStyle = true S3AssumeRoleArn = "" S3AssumeRoleExternalID = "" S3MultiRegion = false @@ -539,6 +541,7 @@ func Configure() error { configurators.Bool(&S3Enabled, "IMGPROXY_USE_S3") configurators.String(&S3Region, "IMGPROXY_S3_REGION") configurators.String(&S3Endpoint, "IMGPROXY_S3_ENDPOINT") + configurators.Bool(&S3EndpointUsePathStyle, "IMGPROXY_S3_ENDPOINT_USE_PATH_STYLE") configurators.String(&S3AssumeRoleArn, "IMGPROXY_S3_ASSUME_ROLE_ARN") configurators.String(&S3AssumeRoleExternalID, "IMGPROXY_S3_ASSUME_ROLE_EXTERNAL_ID") configurators.Bool(&S3MultiRegion, "IMGPROXY_S3_MULTI_REGION") diff --git a/transport/s3/s3.go b/transport/s3/s3.go index eecd7dd7..757a162b 100644 --- a/transport/s3/s3.go +++ b/transport/s3/s3.go @@ -84,7 +84,7 @@ func New() (http.RoundTripper, error) { } clientOptions = append(clientOptions, func(o *s3.Options) { o.BaseEndpoint = aws.String(endpoint) - o.UsePathStyle = true + o.UsePathStyle = config.S3EndpointUsePathStyle }) }