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 2020/09/18 06:52:24 UTC
[GitHub] [apisix] TigerGxl opened a new issue #2257: request help: http_to_https ret_code 307 not working
TigerGxl opened a new issue #2257:
URL: https://github.com/apache/apisix/issues/2257
### Issue description
### Environment
* apisix version (cmd: `apisix version`):1.5
* OS:ubuntu16.04
i use plugin http_to_https and set ret_code 307, like below.
```
{
"priority": 0,
"plugins": {
"redirect": {
"ret_code": 307,
"http_to_https": true
}
},
"uris": [
"/*"
],
"id": "1a5f4337d",
"hosts": [
"demo-apisix.xxxxxxx.com"
],
"upstream": {
"nodes": {
"172.16.3.2:80": 100
},
"hash_on": "vars",
"type": "roundrobin"
}
}
```
when client sends **POST** reqeust with **http**.it's not working, apisix should return 307 and client sends a new request with https again, in fact, apisix return 301 and client sends a new request with **https** and the method is **GET**


----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] TigerGxl commented on issue #2257: request help: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
TigerGxl commented on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-695995678
启用http跳转https后,设置状态码为307不生效,etcd中存储的是301,但是实际跳转的时候是301,导致原本POST的method在301跳转后变为GET
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] liuhengloveyou commented on issue #2257: bug: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
liuhengloveyou commented on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698702015
If the user has explicitly configured `ret_code`, we should not change it.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #2257: bug: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698702658
@gy09535
I think you mean 308 but not 307: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308
Code 307 is 'Temporary'.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] membphis commented on issue #2257: bug: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
membphis commented on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698096059
the patch
```patch
diff --git a/apisix/plugins/redirect.lua b/apisix/plugins/redirect.lua
index 64819735..eb386dea 100644
--- a/apisix/plugins/redirect.lua
+++ b/apisix/plugins/redirect.lua
@@ -133,7 +133,7 @@ function _M.rewrite(conf, ctx)
-- TODO: add test case
-- PR: https://github.com/apache/apisix/pull/1958
uri = "https://$host$request_uri"
- ret_code = 301
+ ret_code = ret_code or 301
end
if uri and ret_code then
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] moonming closed issue #2257: bug: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
moonming closed issue #2257:
URL: https://github.com/apache/apisix/issues/2257
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] liuhengloveyou edited a comment on issue #2257: bug: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
liuhengloveyou edited a comment on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698702015
If the user has explicitly configured `ret_code`, we should not change it.
Unless the configuration is wrong, we should indicate the range in the documentation.
I think the range of ` should` be `400 > ret_code >= 300`?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] membphis removed a comment on issue #2257: bug: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
membphis removed a comment on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698096059
the patch
```patch
diff --git a/apisix/plugins/redirect.lua b/apisix/plugins/redirect.lua
index 64819735..eb386dea 100644
--- a/apisix/plugins/redirect.lua
+++ b/apisix/plugins/redirect.lua
@@ -133,7 +133,7 @@ function _M.rewrite(conf, ctx)
-- TODO: add test case
-- PR: https://github.com/apache/apisix/pull/1958
uri = "https://$host$request_uri"
- ret_code = 301
+ ret_code = ret_code or 301
end
if uri and ret_code then
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] gy09535 edited a comment on issue #2257: bug: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
gy09535 edited a comment on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698682866
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #2257: bug: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698702658
@gy09535
I think you mean 308 but not 307: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308
Code 307 is 'Temporary'.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] gy09535 edited a comment on issue #2257: bug: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
gy09535 edited a comment on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698704288
> @gy09535
> I think you mean 308 but not 307: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308
> Code 307 is 'Temporary'.
yeah, should be 308
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] liuhengloveyou edited a comment on issue #2257: bug: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
liuhengloveyou edited a comment on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698702015
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] membphis commented on issue #2257: request help: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
membphis commented on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698095505
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] gy09535 commented on issue #2257: bug: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
gy09535 commented on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698682866
I thinks when we send redirect to 301 ,some browser default change the request to get, so we should add some logical to handle post request , when the request is post we should send the ret_code to 307
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] gy09535 edited a comment on issue #2257: bug: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
gy09535 edited a comment on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698682866
I thinks when we send redirect to 301 ,some browser default change the request to get, so we should add some logical to handle post request , when the request is post we should send the ret_code to 307, according to https://github.com/apache/apisix/blob/master/apisix/plugins/redirect.lua#L136
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] TigerGxl edited a comment on issue #2257: request help: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
TigerGxl edited a comment on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-695995678
启用http跳转https后,设置状态码为307不生效.
etcd中存储的状态码是307,但是实际跳转的时候是301,导致原本POST的method在301跳转后变为GET
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] gy09535 commented on issue #2257: bug: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
gy09535 commented on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698704288
> @gy09535
> I think you mean 308 but not 307: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308
> Code 307 is 'Temporary'.
yeah, should be 308
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] liuhengloveyou commented on issue #2257: bug: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
liuhengloveyou commented on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698702015
If the user has explicitly configured `ret_code`, we should not change it.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] TigerGxl commented on issue #2257: request help: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
TigerGxl commented on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-695995678
启用http跳转https后,设置状态码为307不生效,etcd中存储的是301,但是实际跳转的时候是301,导致原本POST的method在301跳转后变为GET
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] membphis commented on issue #2257: request help: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
membphis commented on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698095505
that is a bug. here is the test case. welcome PR to fix it
```
=== TEST 1: add plugin with new uri: /test/add
--- 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,
[[{
"plugins": {
"redirect": {
"http_to_https": true,
"ret_code": 307
}
},
"uri": "/hello"
}]]
)
if code >= 300 then
ngx.status = code
end
ngx.say(body)
}
}
--- request
GET /t
--- response_body
passed
--- no_error_log
[error]
=== TEST 2: redirect
--- request
GET /hello
--- response_headers
Location: /test/add
--- error_code: 307
--- 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] membphis removed a comment on issue #2257: bug: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
membphis removed a comment on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698096059
the patch
```patch
diff --git a/apisix/plugins/redirect.lua b/apisix/plugins/redirect.lua
index 64819735..eb386dea 100644
--- a/apisix/plugins/redirect.lua
+++ b/apisix/plugins/redirect.lua
@@ -133,7 +133,7 @@ function _M.rewrite(conf, ctx)
-- TODO: add test case
-- PR: https://github.com/apache/apisix/pull/1958
uri = "https://$host$request_uri"
- ret_code = 301
+ ret_code = ret_code or 301
end
if uri and ret_code then
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] gy09535 commented on issue #2257: bug: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
gy09535 commented on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698682866
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] TigerGxl edited a comment on issue #2257: request help: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
TigerGxl edited a comment on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-695995678
启用http跳转https后,设置状态码为307不生效.
etcd中存储的状态码是307,但是实际跳转的时候是301,导致原本POST的method在301跳转后变为GET
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] moonming commented on issue #2257: bug: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
moonming commented on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698113768
@liuhengloveyou please take a look
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] moonming commented on issue #2257: bug: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
moonming commented on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698113768
@liuhengloveyou please take a look
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] liuhengloveyou edited a comment on issue #2257: bug: http_to_https ret_code 307 not working
Posted by GitBox <gi...@apache.org>.
liuhengloveyou edited a comment on issue #2257:
URL: https://github.com/apache/apisix/issues/2257#issuecomment-698702015
If the user has explicitly configured `ret_code`, we should not change it.
Unless the configuration is wrong, we should indicate the range in the documentation.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org