You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/05/17 15:00:59 UTC

[GitHub] [apisix] tzssangglass commented on a diff in pull request #7065: fix: redirect http to https but port not change

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


##########
apisix/plugins/redirect.lua:
##########
@@ -148,7 +150,32 @@ 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("redirect")

Review Comment:
   ```suggestion
       local attr = plugin.plugin_attr(plugin_name)
   ```



##########
apisix/plugins/redirect.lua:
##########
@@ -148,7 +150,32 @@ 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("redirect")
+    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")

Review Comment:
   ```suggestion
           local ssl = core.table.try_read_attr(local_conf, "apisix", "ssl")
   ```



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org