-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: add curl test for redirect plugin's http_to_https
.
#6378
docs: add curl test for redirect plugin's http_to_https
.
#6378
Conversation
Signed-off-by: mango <xu.weiKyrie@foxmail.com>
docs/en/latest/plugins/redirect.md
Outdated
$ curl http://127.0.0.1:9080/hello -i | ||
HTTP/1.1 301 Moved Permanently | ||
... | ||
Location: https://127.0.0.1/hello |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we use 9080
to accept HTTP traffic, should we use 9443
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should be 9443
? and the default port of https
is 443
.
When http_to_https
is set to true and the request is HTTP, it will be automatically redirected to HTTPS with 301 response code, and the URI will keep the same as client request.
apisix/apisix/plugins/redirect.lua
Lines 155 to 166 in 9b98f1d
if conf.http_to_https and _scheme == "http" then | |
-- TODO: add test case | |
-- PR: https://github.com/apache/apisix/pull/1958 | |
uri = "https://$host$request_uri" | |
local method_name = ngx.req.get_method() | |
if method_name == "GET" or method_name == "HEAD" then | |
ret_code = 301 | |
else | |
-- https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308 | |
ret_code = 308 | |
end | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should be
9443
The default port for the APISIX proxy https protocol is 9443.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mangoGoForward Just for the consistence of the documentation, look through the whole doc you'll find we don't use the default 80
port.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default port for the APISIX proxy https protocol is 9443.
@tokers See the Location
header of response, it redirected to https
. And I found some test cases in t/plugin/redirect.t
:
Lines 431 to 438 in 42e84e4
=== TEST 18: redirect | |
--- request | |
GET /hello | |
--- more_headers | |
Host: foo.com | |
--- error_code: 301 | |
--- response_headers | |
Location: https://foo.com/hello |
Seems we don't need to update?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I think there is a bug, The generated Location header should respect the setting of SSL port, we cannot assume the SSL port is 443
.
Also, my original meaning is quite simple, just because we use 9080
as the sample port to accept HTTP traffic in the doc, for the sake for consistence, I think using 9443
is better. If we use 80
to accept HTTP traffic, then using 443
is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't know how to use 9443
in this test case.
Do we need create an upstream?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR does not need to be modified in the test case to 9443, just use 9443 in the documentation? cc @tokers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping @tokers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tzssangglass is correct, just use 9443
in documentation is enough.
Co-authored-by: tzssangglass <tzssangglass@gmail.com>
Co-authored-by: tzssangglass <tzssangglass@gmail.com>
What this PR does / why we need it:
Add curl test for redirect plugin's
http_to_https
, please see #3931.Pre-submission checklist: