]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: civetweb accepts multiple port= entries
authorCasey Bodley <cbodley@redhat.com>
Tue, 23 Jan 2018 18:37:05 +0000 (13:37 -0500)
committerCasey Bodley <cbodley@redhat.com>
Tue, 30 Jan 2018 18:35:30 +0000 (13:35 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
doc/radosgw/frontends.rst
src/rgw/rgw_civetweb_frontend.cc

index c3c73b7de8c226b92e3f272be787ad0268b08119..e28a602e5895305e32c5e56aff9019c6b6633bc2 100644 (file)
@@ -43,7 +43,8 @@ Options
 :Description: Sets the listening port number. For SSL-enabled ports, add an
               ``s`` suffix like ``443s``. To bind a specific IPv4 or IPv6
               address, use the form ``address:port``. Multiple endpoints
-              can be separated by ``+`` as in ``127.0.0.1:8000+443s``.
+              can either be separated by ``+`` as in ``127.0.0.1:8000+443s``,
+              or by providing multiple options as in ``port=8000 port=443s``.
 
 :Type: String
 :Default: ``7480``
index d0d4942943930bd2c71b1490e28938b87c4b9392..33e00144647ee8a337f01b9c27ad9dff940fe3a4 100644 (file)
@@ -50,7 +50,6 @@ int RGWCivetWebFrontend::process(struct mg_connection*  const conn)
 int RGWCivetWebFrontend::run()
 {
   auto& conf_map = conf->get_config_map();
-  string port_str;
 
   set_conf_default(conf_map, "num_threads",
                    std::to_string(g_conf->rgw_thread_pool_size));
@@ -59,9 +58,23 @@ int RGWCivetWebFrontend::run()
   set_conf_default(conf_map, "validate_http_method", "no");
   set_conf_default(conf_map, "canonicalize_url_path", "no");
   set_conf_default(conf_map, "enable_auth_domain_check", "no");
-  conf->get_val("port", "80", &port_str);
-  std::replace(port_str.begin(), port_str.end(), '+', ',');
-  conf_map.emplace("listening_ports", std::move(port_str));
+
+  std::string listening_ports;
+  // support multiple port= entries
+  auto range = conf_map.equal_range("port");
+  for (auto p = range.first; p != range.second; ++p) {
+    std::string port_str = p->second;
+    // support port= entries with multiple values
+    std::replace(port_str.begin(), port_str.end(), '+', ',');
+    if (!listening_ports.empty()) {
+      listening_ports.append(1, ',');
+    }
+    listening_ports.append(port_str);
+  }
+  if (listening_ports.empty()) {
+    listening_ports = "80";
+  }
+  conf_map.emplace("listening_ports", std::move(listening_ports));
 
   /* Set run_as_user. This will cause civetweb to invoke setuid() and setgid()
    * based on pw_uid and pw_gid obtained from pw_name. */