From f62fff1f4c46d6dfa1b0fe4cb0e4594192561c4c Mon Sep 17 00:00:00 2001 From: Giuseppe Baccini Date: Wed, 19 Oct 2022 16:58:05 +0200 Subject: [PATCH] rgw: add multivalue support to rgw_dns_name config option rgw_dns_name configuration option has extended to define multiple domain values. This option is now interpreted as a comma separated list of DNS names. Example: rgw_dns_name = cname.domain.com,cname2.domain2.com, cname3.domain3.com Signed-off-by: Giuseppe Baccini --- doc/radosgw/s3/commons.rst | 2 ++ src/common/options/rgw.yaml.in | 7 ++++--- src/rgw/rgw_rest.cc | 8 ++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/doc/radosgw/s3/commons.rst b/doc/radosgw/s3/commons.rst index ca848bc277e..4b9b4a040ab 100644 --- a/doc/radosgw/s3/commons.rst +++ b/doc/radosgw/s3/commons.rst @@ -22,6 +22,8 @@ To configure virtual hosted buckets, you can either set ``rgw_dns_name = cname.d .. tip:: We prefer the first method, because the second method requires expensive domain certification and DNS wild cards. +.. tip:: You can define multiple hostname directly with the :confval:`rgw_dns_name` parameter. + Common Request Headers ---------------------- diff --git a/src/common/options/rgw.yaml.in b/src/common/options/rgw.yaml.in index 33fe0a60794..d705841af9d 100644 --- a/src/common/options/rgw.yaml.in +++ b/src/common/options/rgw.yaml.in @@ -282,10 +282,11 @@ options: - name: rgw_dns_name type: str level: advanced - desc: The host name that RGW uses. - long_desc: This is Needed for virtual hosting of buckets to work properly, unless + desc: The host names that RGW uses. + long_desc: A comma separated list of DNS names. + This is Needed for virtual hosting of buckets to work properly, unless configured via zonegroup configuration. - fmt_desc: The DNS name of the served domain. See also the ``hostnames`` setting within regions. + fmt_desc: The DNS names of the served domains. See also the ``hostnames`` setting within zonegroups. services: - rgw with_legacy: true diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index 80538467393..29b28fa6080 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -209,10 +209,14 @@ void rgw_rest_init(CephContext *cct, const rgw::sal::ZoneGroup& zone_group) for (const struct rgw_http_status_code *h = http_codes; h->code; h++) { http_status_names[h->code] = h->name; } - std::list names; + std::list rgw_dns_names; + std::string rgw_dns_names_str = cct->_conf->rgw_dns_name; + get_str_list(rgw_dns_names_str, ", ", rgw_dns_names); + hostnames_set.insert(rgw_dns_names.begin(), rgw_dns_names.end()); + + std::list names; zone_group.get_hostnames(names); - hostnames_set.insert(cct->_conf->rgw_dns_name); hostnames_set.insert(names.begin(), names.end()); hostnames_set.erase(""); // filter out empty hostnames ldout(cct, 20) << "RGW hostnames: " << hostnames_set << dendl;