Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Add a new flag to support S3 path style URLs without disabling SSL

Manav Rathi92ae1be40a9c
diff --git a/server/configurations/local.yaml b/server/configurations/local.yaml
index 2c4bd8f3ce..4bab089b6a 100644
--- a/server/configurations/local.yaml
+++ b/server/configurations/local.yaml
@@ -113,10 +113,7 @@ s3:
#
# 1. Disable SSL.
#
- # 2. Use "path" style S3 URLs where the bucket is part of the URL path, e.g.
- # http://localhost:3200/b2-eu-cen. By default the bucket name is part of
- # the (sub)domain, e.g. http://b2-eu-cen.localhost:3200/ and cannot be
- # resolved when running locally.
+ # 2. Use "path" style S3 URLs (see `use_path_style_urls` below).
#
# 3. Directly download the file during replication instead of going via the
# Cloudflare worker.
@@ -125,6 +122,17 @@ s3:
# not support them, specifically it doesn't support GLACIER).
#
#are_local_buckets: true
+ # Uncomment this to use "path" style S3 URLs.
+ #
+ # By default the bucket name is part of the (sub)domain, e.g.
+ # http://b2-eu-cen.localhost:3200/. If this is true, then we use "path"
+ # style S3 URLs where the bucket is part of the URL path, e.g.
+ # http://localhost:3200/b2-eu-cen.
+ #
+ # This is useful in scenarios when sub-domain based addressing cannot be
+ # resolved, e.g. when running a local instance, or when using MinIO as a
+ # production store.
+ #use_path_style_urls: true
# Key used for encrypting customer emails before storing them in DB
#
diff --git a/server/pkg/utils/s3config/s3config.go b/server/pkg/utils/s3config/s3config.go
index fe83ce6ea3..9b273bd612 100644
--- a/server/pkg/utils/s3config/s3config.go
+++ b/server/pkg/utils/s3config/s3config.go
@@ -104,6 +104,7 @@ func (config *S3Config) initialize() {
config.s3Configs = make(map[string]*aws.Config)
config.s3Clients = make(map[string]s3.S3)
+ usePathStyleURLs := viper.GetBool("s3.use_path_style_urls")
areLocalBuckets := viper.GetBool("s3.are_local_buckets")
config.areLocalBuckets = areLocalBuckets
@@ -116,6 +117,9 @@ func (config *S3Config) initialize() {
Endpoint: aws.String(viper.GetString("s3." + dc + ".endpoint")),
Region: aws.String(viper.GetString("s3." + dc + ".region")),
}
+ if usePathStyleURLs {
+ s3Config.S3ForcePathStyle = aws.Bool(true)
+ }
if areLocalBuckets {
s3Config.DisableSSL = aws.Bool(true)
s3Config.S3ForcePathStyle = aws.Bool(true)