Skip to content

Commit 12154f2

Browse files
committed
rgw/rgw_rest: determine the domain uri prefix by rgw_transport_is_secure
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 <[email protected]>
1 parent 9238442 commit 12154f2

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/rgw/rgw_rest.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -888,8 +888,7 @@ inline std::string compute_domain_uri(const req_state *s) {
888888
std::string uri = (!s->info.domain.empty()) ? s->info.domain :
889889
[&s]() -> std::string {
890890
RGWEnv const &env(*(s->info.env));
891-
std::string uri =
892-
env.get("SERVER_PORT_SECURE") ? "https://" : "http://";
891+
std::string uri = rgw_transport_is_secure(s->cct, env) ? "https://" : "http://";
893892
if (env.exists("SERVER_NAME")) {
894893
uri.append(env.get("SERVER_NAME", "<SERVER_NAME>"));
895894
} else {

src/rgw/rgw_rest_s3.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5914,7 +5914,7 @@ int RGWHandler_REST_S3Website::retarget(RGWOp* op, RGWOp** new_op, optional_yiel
59145914
if (should_redirect) {
59155915
const string& hostname = s->info.env->get("HTTP_HOST", "");
59165916
const string& protocol =
5917-
(s->info.env->get("SERVER_PORT_SECURE") ? "https" : "http");
5917+
(rgw_transport_is_secure(s->cct, *s->info.env) ? "https" : "http");
59185918
int redirect_code = 0;
59195919
rrule.apply_rule(protocol, hostname, key_name, &s->redirect,
59205920
&redirect_code);
@@ -6045,7 +6045,7 @@ int RGWHandler_REST_S3Website::error_handler(int err_no,
60456045
if (should_redirect) {
60466046
const string& hostname = s->info.env->get("HTTP_HOST", "");
60476047
const string& protocol =
6048-
(s->info.env->get("SERVER_PORT_SECURE") ? "https" : "http");
6048+
(rgw_transport_is_secure(s->cct, *s->info.env) ? "https" : "http");
60496049
int redirect_code = 0;
60506050
rrule.apply_rule(protocol, hostname, original_object_name,
60516051
&s->redirect, &redirect_code);

0 commit comments

Comments
 (0)