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/02/01 16:42:23 UTC

[GitHub] [apisix] soham4abc opened a new pull request #6242: feat: Patched Redirect Plugin

soham4abc opened a new pull request #6242:
URL: https://github.com/apache/apisix/pull/6242


   ### What this PR does / why we need it:
   Fixes #6078 
   <!--- Why is this change required? What problem does it solve? -->
   <!--- If it fixes an open issue, please link to the issue here. -->
   
   ### Pre-submission checklist:
   
   <!--
   Please follow the PR manners:
   1. Use Draft if the PR is not ready to be reviewed
   2. Test is required for the feat/fix PR, unless you have a good reason
   3. Doc is required for the feat PR
   4. Use a new commit to resolve review instead of `push -f`
   5. If you need to resolve merge conflicts after the PR is reviewed, please merge master but do not rebase
   6. Use "request review" to notify the reviewer once you have resolved the review
   7. Only reviewer can click "Resolve conversation" to mark the reviewer's review resolved
   -->
   
   * [ ] Did you explain what problem does this PR solve? Or what new features have been added?
   * [ ] Have you added corresponding test cases?
   * [ ] Have you modified the corresponding document?
   * [ ] Is this PR backward compatible? **If it is not backward compatible, please discuss on the [mailing list](https://github.com/apache/apisix/tree/master#community) first**
   


-- 
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



[GitHub] [apisix] spacewander commented on a change in pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
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&name=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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] soham4abc commented on a change in pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
soham4abc commented on a change in pull request #6242:
URL: https://github.com/apache/apisix/pull/6242#discussion_r804797937



##########
File path: t/plugin/redirect.t
##########
@@ -1000,3 +1000,58 @@ Location: /hello?type=string&name=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:
       You meant line 1030 right??




-- 
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



[GitHub] [apisix] soham4abc commented on a change in pull request #6242: feat: Patched Redirect Plugin

Posted by GitBox <gi...@apache.org>.
soham4abc commented on a change in pull request #6242:
URL: https://github.com/apache/apisix/pull/6242#discussion_r797820222



##########
File path: docs/en/latest/architecture-design/apisix.md
##########
@@ -25,6 +25,10 @@ title: APISIX
 
 ![flow-software-architecture](../../../assets/images/flow-software-architecture.png)
 
+## Apache APISIX : Software Architecture
+
+![flow-software-architecture](../../../assets/images/flow-software-architecture.png)
+

Review comment:
       Yes, I am removing this in a minute
   




-- 
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



[GitHub] [apisix] bisakhmondal commented on a change in pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
bisakhmondal commented on a change in pull request #6242:
URL: https://github.com/apache/apisix/pull/6242#discussion_r797834127



##########
File path: docs/en/latest/architecture-design/apisix.md
##########
@@ -25,6 +25,10 @@ title: APISIX
 
 ![flow-software-architecture](../../../assets/images/flow-software-architecture.png)
 
+## Apache APISIX : Software Architecture
+
+![flow-software-architecture](../../../assets/images/flow-software-architecture.png)
+

Review comment:
       Thanks for addressing the change
   




-- 
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



[GitHub] [apisix] soham4abc commented on pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
soham4abc commented on pull request #6242:
URL: https://github.com/apache/apisix/pull/6242#issuecomment-1029193478


   > > @bisakhmondal Could you help @soham4abc to add a test for it?
   > 
   > Yes sure. @soham4abc we use test-nginx in APISIX for testing. You can find the docs here (https://github.com/apache/apisix/blob/master/docs/en/latest/internal/testing-framework.md)
   > 
   > Feel free to go through the existing redirect plugin tests here (https://github.com/apache/apisix/blob/master/t/plugin/redirect.t) and add a test case there. I can think of two options:
   > 
   > 1. Treating the test suite endpoint itself as a proxy
   > 2. Setup a mock HTTP route, that acts as a proxy to forward the request to the apisix test suite.
   > 
   > Totally up to you. Thank you!
   
   Hey @bisakhmondal ,
   
   Sorry as I am new to this codebase and do not have much experience regarding it. Would be nice if you raise a separate issue and PR for this. 
   
   I am sorry I couldn't deliver the testcases as of now!
   
   Thank you


-- 
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



[GitHub] [apisix] soham4abc commented on a change in pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
soham4abc commented on a change in pull request #6242:
URL: https://github.com/apache/apisix/pull/6242#discussion_r805494162



##########
File path: t/plugin/redirect.t
##########
@@ -1000,3 +1000,58 @@ Location: /hello?type=string&name=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:
       Done as per request




-- 
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



[GitHub] [apisix] spacewander merged pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
spacewander merged pull request #6242:
URL: https://github.com/apache/apisix/pull/6242


   


-- 
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



[GitHub] [apisix] soham4abc commented on pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
soham4abc commented on pull request #6242:
URL: https://github.com/apache/apisix/pull/6242#issuecomment-1033774171


   Thanks a lot @tzssangglass  and @bisakhmondal  For guiding me in this issue!
   


-- 
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



[GitHub] [apisix] bisakhmondal commented on a change in pull request #6242: feat: Patched Redirect Plugin

Posted by GitBox <gi...@apache.org>.
bisakhmondal commented on a change in pull request #6242:
URL: https://github.com/apache/apisix/pull/6242#discussion_r797812096



##########
File path: docs/en/latest/architecture-design/apisix.md
##########
@@ -25,6 +25,10 @@ title: APISIX
 
 ![flow-software-architecture](../../../assets/images/flow-software-architecture.png)
 
+## Apache APISIX : Software Architecture
+
+![flow-software-architecture](../../../assets/images/flow-software-architecture.png)
+

Review comment:
       Redundant?




-- 
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



[GitHub] [apisix] bisakhmondal commented on pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
bisakhmondal commented on pull request #6242:
URL: https://github.com/apache/apisix/pull/6242#issuecomment-1028625979


   > @bisakhmondal Could you help @soham4abc to add a test for it?
   
   Yes sure. @soham4abc we use test-nginx in APISIX for testing. You can find the docs here (https://github.com/apache/apisix/blob/master/docs/en/latest/internal/testing-framework.md)
   
   Feel free to go through the existing redirect plugin tests here (https://github.com/apache/apisix/blob/master/t/plugin/redirect.t) and add a test case there. I can think of two options:
   1. Treating the test suite endpoint itself as a proxy
   2. Setup a mock HTTP route, that acts as a proxy to forward the request to the apisix test suite.
   
   Totally up to you. Thank you!
   
   


-- 
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



[GitHub] [apisix] spacewander commented on a change in pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] soham4abc commented on pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
soham4abc commented on pull request #6242:
URL: https://github.com/apache/apisix/pull/6242#issuecomment-1039272826


   Thank you everyone


-- 
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



[GitHub] [apisix] tzssangglass commented on a change in pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on a change in pull request #6242:
URL: https://github.com/apache/apisix/pull/6242#discussion_r802219849



##########
File path: t/plugin/redirect.t
##########
@@ -1000,3 +1000,44 @@ Location: /hello?type=string&name=json
 --- error_code: 302
 --- no_error_log
 [error]
+
+
+
+=== TEST 41: redirect

Review comment:
       ```suggestion
   === TEST 41: enable http_to_https (pass X-Forwarded-Proto)
   ```

##########
File path: t/plugin/redirect.t
##########
@@ -1000,3 +1000,44 @@ Location: /hello?type=string&name=json
 --- error_code: 302
 --- no_error_log
 [error]
+
+
+
+=== TEST 41: redirect
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("plugin.redirect").test
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "uri": "/hello",
+                    "host": "foo.com",
+                    "vars": [
+                        [
+                            "scheme",
+                            "==",
+                            "http"
+                        ]
+                    ],
+                    "plugins": {
+                        "redirect": {
+                            "uri": "https://$host$request_uri",
+                            "ret_code": 301
+                        }
+                    }
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]

Review comment:
       and add a test case like 
   
   
   ```
   === TEST 2: enable http_to_https (pass X-Forwarded-Proto)
   --- request
   GET /hello
   --- more_headers
   Host: foo.com
   X-Forwarded-Proto: http
   --- error_code: 301
   --- response_headers
   Location: https://foo.com/hello
   ```

##########
File path: t/plugin/redirect.t
##########
@@ -1000,3 +1000,44 @@ Location: /hello?type=string&name=json
 --- error_code: 302
 --- no_error_log
 [error]
+
+
+
+=== TEST 41: redirect
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("plugin.redirect").test
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "uri": "/hello",
+                    "host": "foo.com",
+                    "vars": [
+                        [
+                            "scheme",
+                            "==",
+                            "http"
+                        ]
+                    ],
+                    "plugins": {
+                        "redirect": {
+                            "uri": "https://$host$request_uri",
+                            "ret_code": 301

Review comment:
       ```suggestion
                               "http_to_https": true
   ```




-- 
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



[GitHub] [apisix] tzssangglass commented on a change in pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on a change in pull request #6242:
URL: https://github.com/apache/apisix/pull/6242#discussion_r802304473



##########
File path: t/plugin/redirect.t
##########
@@ -1000,3 +1000,49 @@ Location: /hello?type=string&name=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:
       lost 
   
   ```
   --- request
   GET /t
   --- response_body
   passed
   --- no_error_log
   [error]
   ```




-- 
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



[GitHub] [apisix] soham4abc commented on pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
soham4abc commented on pull request #6242:
URL: https://github.com/apache/apisix/pull/6242#issuecomment-1039272826


   Thank you everyone


-- 
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



[GitHub] [apisix] soham4abc commented on pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
soham4abc commented on pull request #6242:
URL: https://github.com/apache/apisix/pull/6242#issuecomment-1030762769


   Any issues? @bisakhmondal 


-- 
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



[GitHub] [apisix] soham4abc commented on pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
soham4abc commented on pull request #6242:
URL: https://github.com/apache/apisix/pull/6242#issuecomment-1030825353


   > Adding a test for it is easy. Could you follow @bisakhmondal 's guide to add a test?
   > A test is required to prevent regression.
   
   Sure... Just might take some time! 


-- 
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



[GitHub] [apisix] soham4abc commented on a change in pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
soham4abc commented on a change in pull request #6242:
URL: https://github.com/apache/apisix/pull/6242#discussion_r804790452



##########
File path: t/plugin/redirect.t
##########
@@ -1000,3 +1000,58 @@ Location: /hello?type=string&name=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:
       @spacewander  Won't removing the extra lines make lint errors??




-- 
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



[GitHub] [apisix] tzssangglass commented on a change in pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on a change in pull request #6242:
URL: https://github.com/apache/apisix/pull/6242#discussion_r802196294



##########
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 or ctx.var.scheme

Review comment:
       ```suggestion
       local proxy_proto = core.request.header(ctx, "X-Forwarded-Proto")
       local _scheme = proxy_proto or core.request.get_scheme(ctx)
   ```

##########
File path: t/plugin/redirect.t
##########
@@ -1000,3 +1000,44 @@ Location: /hello?type=string&name=json
 --- error_code: 302
 --- no_error_log
 [error]
+
+
+
+=== TEST 41: redirect
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("plugin.redirect").test

Review comment:
       ```suggestion
               local t = require("lib.test_admin").test
   ```




-- 
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



[GitHub] [apisix] spacewander commented on a change in pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
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&name=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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] spacewander commented on a change in pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
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&name=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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] spacewander merged pull request #6242: fix(redirect-plugin): redirection loop behind a proxy or lb

Posted by GitBox <gi...@apache.org>.
spacewander merged pull request #6242:
URL: https://github.com/apache/apisix/pull/6242


   


-- 
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