]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/rgw_rest: determine the domain uri prefix by rgw_transport_is_secure 63363/head
authorXuehan Xu <xuxuehan@qianxin.com>
Wed, 7 May 2025 04:37:52 +0000 (12:37 +0800)
committerCasey Bodley <cbodley@redhat.com>
Mon, 19 May 2025 23:29:04 +0000 (19:29 -0400)
Instead of relying only on SERVER_PORT_SECURE.

This is useful when a proxy is used in front of the rgw for ssl
terminations.

Fixes: https://tracker.ceph.com/issues/71229
Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
(cherry picked from commit 12154f287eb86c4dd48d7b6f02c725e858ff99ab)

src/rgw/rgw_rest.h
src/rgw/rgw_rest_s3.cc

index fae60c50f4ddda582055d4b2c12e15babad68eaf..236101598f69c242ec53b40bf414a3d416c971bd 100644 (file)
@@ -806,8 +806,7 @@ inline std::string compute_domain_uri(const req_state *s) {
   std::string uri = (!s->info.domain.empty()) ? s->info.domain :
     [&s]() -> std::string {
     RGWEnv const &env(*(s->info.env));
-    std::string uri =
-    env.get("SERVER_PORT_SECURE") ? "https://" : "http://";
+    std::string uri = rgw_transport_is_secure(s->cct, env) ? "https://" : "http://";
     if (env.exists("SERVER_NAME")) {
       uri.append(env.get("SERVER_NAME", "<SERVER_NAME>"));
     } else {
index e0d52a680b6e9f0417cae92b770fae16105bbfcd..fe8b56c27d1695ee65ce947183df78c033dcdfc9 100644 (file)
@@ -5349,7 +5349,7 @@ int RGWHandler_REST_S3Website::retarget(RGWOp* op, RGWOp** new_op, optional_yiel
   if (should_redirect) {
     const string& hostname = s->info.env->get("HTTP_HOST", "");
     const string& protocol =
-      (s->info.env->get("SERVER_PORT_SECURE") ? "https" : "http");
+      (rgw_transport_is_secure(s->cct, *s->info.env) ? "https" : "http");
     int redirect_code = 0;
     rrule.apply_rule(protocol, hostname, key_name, &s->redirect,
                    &redirect_code);
@@ -5480,7 +5480,7 @@ int RGWHandler_REST_S3Website::error_handler(int err_no,
   if (should_redirect) {
     const string& hostname = s->info.env->get("HTTP_HOST", "");
     const string& protocol =
-      (s->info.env->get("SERVER_PORT_SECURE") ? "https" : "http");
+      (rgw_transport_is_secure(s->cct, *s->info.env) ? "https" : "http");
     int redirect_code = 0;
     rrule.apply_rule(protocol, hostname, original_object_name,
                      &s->redirect, &redirect_code);