-
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
fix(redirect): set redirect server port when enable http_to_https #6686
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
20d3037
feat(plugin-redirect): set redirect server port when enable http_to_h…
kwanhur b18a5a6
feat(plugin-redirect): set redirect server port when enable http_to_h…
kwanhur a886510
style: reindex t/plugin/redirect.t
kwanhur cab61f9
style: merge pull
kwanhur fc97e85
style: reindex t/plugin/redirect.t
kwanhur 6e1e331
Merge branch 'feat-redirect-port' of github.com:kwanhur/apisix into f…
kwanhur 5f344e0
chore: merge master and fix conflicts
kwanhur 4726d79
feat(redirect): redirect server port with x-forwarded-port when enabl…
kwanhur 721aa8f
feat(redirect): redirect to well-known port when ret_port nil
kwanhur 76007ac
feat(redirect): redirect to well-known port when ret_port less than z…
kwanhur 8767233
docs: update plugin redirect port when http_to_https at en usage
kwanhur 75fa6f1
docs: update plugin redirect port when http_to_https at zh usage
kwanhur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Recently, I upgraded apisix with the latest code, and found that there was an error in converting http to https. When redirecting, I always bring a port 80. It should be caused by this change, because I am listening on port 80 and port 443, but ngx_tpl There is a piece of code in it that is "set $var_x_forwarded_port $server_port;", which means that the port from http to https is always the same. I don't think this change is very reasonable?
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.
Oh, seems I got what you mean. The server port
80
and then enablehttp_to_https
, it'll always redirect tohttps://host:80
then get400 bad request
. cc @tokers @spacewander @tzssangglassWe need to take more consideration about #6686 (comment)
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.
Can we set a default value for this case?
If there is no
X-Forwarded-Port
in clinet reuqest headers, then theredirect
plugin use443
as the default https 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.
It has default as the server_port
apisix/apisix/cli/ngx_tpl.lua
Line 668 in 1b5c190
As mentioned before #6686 (comment)
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.
I mean in the
redirect
plugin, if someone enablehttp_to_https
and the client request doesn't pass X-Forwarded-Port
, use 443 as the default port inLocation
and don't care about theserver_port
variable.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.
In my opinion, it is definitely impossible to know the listening port of https for this domain name if it is not configured from http to https, so it can be considered that the port can be configured, but the default is 443?
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.
As the conversation before #6686 (comment)
The original implement with an extra attribute
ret_port
, but no acceptable.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.
Maybe we can read the correct port from
config.yaml
?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.
把这个set $var_x_forwarded_port $server_port; 改成set $var_x_forwarded_port 443;