diff options
author | Tim Burke <tim.burke@gmail.com> | 2022-01-19 12:50:58 -0800 |
---|---|---|
committer | Tim Burke <tim.burke@gmail.com> | 2022-01-24 15:39:13 -0800 |
commit | 11d10221633bfa586b89aec4395a6f0625d16341 (patch) | |
tree | 954507d7feda4ded7fe7dc4ab2b88db67ea47d6f /swift/common/middleware/s3api/s3request.py | |
parent | 8ef530d795df7f0300e761933c916546427a79fe (diff) | |
download | swift-11d10221633bfa586b89aec4395a6f0625d16341.tar.gz |
s3api: Allow multiple storage domains
Sometimes a cluster might be accessible via more than one set
of domain names. Allow operators to configure them such that
virtual-host style requests work with all names.
Change-Id: I83b2fded44000bf04f558e2deb6553565d54fd4a
Diffstat (limited to 'swift/common/middleware/s3api/s3request.py')
-rw-r--r-- | swift/common/middleware/s3api/s3request.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/swift/common/middleware/s3api/s3request.py b/swift/common/middleware/s3api/s3request.py index d4c33512d..e52a2d4ca 100644 --- a/swift/common/middleware/s3api/s3request.py +++ b/swift/common/middleware/s3api/s3request.py @@ -603,25 +603,25 @@ class S3Request(swob.Request): return 'AWSAccessKeyId' in self.params def _parse_host(self): - storage_domain = self.conf.storage_domain - if not storage_domain: + if not self.conf.storage_domains: return None - if not storage_domain.startswith('.'): - storage_domain = '.' + storage_domain - if 'HTTP_HOST' in self.environ: given_domain = self.environ['HTTP_HOST'] elif 'SERVER_NAME' in self.environ: given_domain = self.environ['SERVER_NAME'] else: return None - port = '' if ':' in given_domain: given_domain, port = given_domain.rsplit(':', 1) - if given_domain.endswith(storage_domain): - return given_domain[:-len(storage_domain)] + + for storage_domain in self.conf.storage_domains: + if not storage_domain.startswith('.'): + storage_domain = '.' + storage_domain + + if given_domain.endswith(storage_domain): + return given_domain[:-len(storage_domain)] return None |