jwrookie commented on code in PR #7065:
URL: https://github.com/apache/apisix/pull/7065#discussion_r875418292


##########
apisix/plugins/redirect.lua:
##########
@@ -148,7 +150,30 @@ function _M.rewrite(conf, ctx)
     core.log.info("plugin rewrite phase, conf: ", core.json.delay_encode(conf))
 
     local ret_code = conf.ret_code
-    local ret_port = tonumber(ctx.var["var_x_forwarded_port"])
+    local ret_port = nil
+    local attr = plugin.plugin_attr(plugin_name)
+    if attr then
+        ret_port = attr.https_port
+    end
+
+    if not ret_port then
+        local local_conf = core.config.local_conf()
+        local ssl = core.table.try_read_attr(local_conf, "apisix", "ssl")
+        if ssl and ssl["enable"] then
+            ret_port = ssl["listen_port"]
+            if not ret_port then
+                local ret_ports = ssl["listen"]
+                if ret_ports and #ret_ports > 0 then
+                    local idx = math_random(1, #ret_ports)
+                    ret_port = ret_ports[idx]
+                    if type(ret_port) == "table" then
+                        ret_port = ret_port.port
+                    end
+                end
+            end
+        end
+    end
+

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to