[GitHub] [apisix] spacewander commented on a change in pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb
spacewander commented on a change in pull request #6242: URL: https://github.com/apache/apisix/pull/6242#discussion_r805327669 ## File path: t/plugin/redirect.t ## @@ -1000,3 +1000,58 @@ Location: /hello?type=string=json --- error_code: 302 --- no_error_log [error] + + + +=== TEST 41: enable http_to_https (pass X-Forwarded-Proto) +--- config +location /t { +content_by_lua_block { +local t = require("lib.test_admin").test +local code, body = t('/apisix/admin/routes/1', +ngx.HTTP_PUT, +[[{ +"uri": "/hello", +"host": "foo.com", +"vars": [ +[ +"scheme", +"==", +"http" +] +], +"plugins": { +"redirect": { +"http_to_https": true +} +} +}]] +) + +if code >= 300 then +ngx.status = code +end +ngx.say(body) +} +} + Review comment: I mean L1037 to L1039 -- 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-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix] spacewander commented on a change in pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb
spacewander commented on a change in pull request #6242: URL: https://github.com/apache/apisix/pull/6242#discussion_r805327669 ## File path: t/plugin/redirect.t ## @@ -1000,3 +1000,58 @@ Location: /hello?type=string=json --- error_code: 302 --- no_error_log [error] + + + +=== TEST 41: enable http_to_https (pass X-Forwarded-Proto) +--- config +location /t { +content_by_lua_block { +local t = require("lib.test_admin").test +local code, body = t('/apisix/admin/routes/1', +ngx.HTTP_PUT, +[[{ +"uri": "/hello", +"host": "foo.com", +"vars": [ +[ +"scheme", +"==", +"http" +] +], +"plugins": { +"redirect": { +"http_to_https": true +} +} +}]] +) + +if code >= 300 then +ngx.status = code +end +ngx.say(body) +} +} + Review comment: I mean L1037 to L1039 -- 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-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix] spacewander commented on a change in pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb
spacewander commented on a change in pull request #6242: URL: https://github.com/apache/apisix/pull/6242#discussion_r803240917 ## File path: t/plugin/redirect.t ## @@ -1000,3 +1000,58 @@ Location: /hello?type=string=json --- error_code: 302 --- no_error_log [error] + + + +=== TEST 41: enable http_to_https (pass X-Forwarded-Proto) +--- config +location /t { +content_by_lua_block { +local t = require("lib.test_admin").test +local code, body = t('/apisix/admin/routes/1', +ngx.HTTP_PUT, +[[{ +"uri": "/hello", +"host": "foo.com", +"vars": [ +[ +"scheme", +"==", +"http" +] +], +"plugins": { +"redirect": { +"http_to_https": true +} +} +}]] +) + +if code >= 300 then +ngx.status = code +end +ngx.say(body) +} +} + Review comment: Let's remove the extra blank lines -- 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-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix] spacewander commented on a change in pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb
spacewander commented on a change in pull request #6242: URL: https://github.com/apache/apisix/pull/6242#discussion_r798220412 ## File path: apisix/plugins/redirect.lua ## @@ -150,7 +150,9 @@ function _M.rewrite(conf, ctx) local uri = conf.uri local regex_uri = conf.regex_uri -if conf.http_to_https and ctx.var.scheme == "http" then +local proxy_proto = core.request.header(ctx, "x-forwarded-proto") +local _scheme = proxy_proto and proxy_proto or ctx.var.scheme Review comment: ```suggestion local _scheme = proxy_proto or ctx.var.scheme ``` -- 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-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org