-
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 http to https but port not change #7065
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9617d41
fix: redirect http to https but port not change
jwrookie 096129b
fix: redirect http to https but port not change
jwrookie 06aa401
fix: redirect http to https but port not change
jwrookie 9b159e1
Apply suggestions from code review
jwrookie c8d2f55
fix: review
jwrookie 155b5b3
Merge branch 'fix/http_to_https' of github.com:jwrookie/apisix into f…
jwrookie 6b38bfe
Apply suggestions from code review
jwrookie b9449f9
Update apisix/plugins/redirect.lua
jwrookie 1ab81b7
fix: review
jwrookie 9c151e5
Merge branch 'fix/http_to_https' of github.com:jwrookie/apisix into f…
jwrookie d965ff8
fix: review
jwrookie 215e66b
fix: review
jwrookie afe5124
Merge remote-tracking branch 'upstream/master' into fix/http_to_https
jwrookie 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -428,59 +428,80 @@ passed | |
|
||
|
||
|
||
=== TEST 18: redirect | ||
=== TEST 18: redirect(port using `plugin_attr.redirect.https_port`) | ||
--- extra_yaml_config | ||
plugin_attr: | ||
redirect: | ||
https_port: 8443 | ||
--- request | ||
GET /hello | ||
--- more_headers | ||
Host: foo.com | ||
--- error_code: 301 | ||
--- response_headers | ||
Location: https://foo.com:1984/hello | ||
Location: https://foo.com:8443/hello | ||
|
||
|
||
|
||
=== TEST 19: redirect(pass well-known port 443 to x-forwarded-port) | ||
=== TEST 19: redirect(port using `apisix.ssl.listen_port`) | ||
--- yaml_config | ||
apisix: | ||
ssl: | ||
enable: true | ||
listen_port: 9445 | ||
--- request | ||
GET /hello | ||
--- more_headers | ||
Host: foo.com | ||
x-forwarded-port: 443 | ||
--- error_code: 301 | ||
--- response_headers | ||
Location: https://foo.com/hello | ||
Location: https://foo.com:9445/hello | ||
|
||
|
||
|
||
=== TEST 20: redirect(pass negative number to x-forwarded-port) | ||
=== TEST 20: redirect(port using `apisix.ssl.listen` when listen length is one) | ||
--- request | ||
GET /hello | ||
--- more_headers | ||
Host: foo.com | ||
x-forwarded-port: -443 | ||
--- error_code: 301 | ||
--- response_headers | ||
Location: https://foo.com/hello | ||
Location: https://foo.com:9443/hello | ||
|
||
|
||
|
||
=== TEST 21: redirect(pass number more than 65535 to x-forwarded-port) | ||
=== TEST 21: redirect(port using `apisix.ssl.listen` when listen length more than one) | ||
--- yaml_config | ||
apisix: | ||
ssl: | ||
enable: true | ||
listen: | ||
- 6443 | ||
- 7443 | ||
- port: 8443 | ||
- port: 9443 | ||
--- request | ||
GET /hello | ||
--- more_headers | ||
Host: foo.com | ||
x-forwarded-port: 65536 | ||
--- error_code: 301 | ||
--- response_headers | ||
Location: https://foo.com/hello | ||
--- response_headers_like | ||
Location: https://foo.com:[6-9]443/hello | ||
|
||
|
||
|
||
=== TEST 22: redirect(pass invalid non-number to x-forwarded-port) | ||
=== TEST 22: redirect(port using `https default port`) | ||
--- yaml_config | ||
apisix: | ||
ssl: | ||
enable: null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add two more test:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
--- extra_yaml_config | ||
plugin_attr: | ||
redirect: null | ||
--- request | ||
GET /hello | ||
--- more_headers | ||
Host: foo.com | ||
x-forwarded-port: ok | ||
--- error_code: 301 | ||
--- response_headers | ||
Location: https://foo.com/hello | ||
|
@@ -528,7 +549,7 @@ GET /hello | |
Host: foo.com | ||
--- error_code: 301 | ||
--- response_headers | ||
Location: https://foo.com:1984/hello | ||
Location: https://foo.com:9443/hello | ||
|
||
|
||
|
||
|
@@ -613,7 +634,7 @@ GET /hello | |
Host: test.com | ||
--- error_code: 301 | ||
--- response_headers | ||
Location: https://test.com:1984/hello | ||
Location: https://test.com:9443/hello | ||
|
||
|
||
|
||
|
@@ -763,7 +784,7 @@ POST /hello-https | |
--- more_headers | ||
Host: test.com | ||
--- response_headers | ||
Location: https://test.com:1984/hello-https | ||
Location: https://test.com:9443/hello-https | ||
--- error_code: 308 | ||
--- no_error_log | ||
[error] | ||
|
@@ -776,7 +797,7 @@ GET /hello-https | |
--- more_headers | ||
Host: test.com | ||
--- response_headers | ||
Location: https://test.com:1984/hello-https | ||
Location: https://test.com:9443/hello-https | ||
--- error_code: 301 | ||
--- no_error_log | ||
[error] | ||
|
@@ -789,7 +810,7 @@ HEAD /hello-https | |
--- more_headers | ||
Host: test.com | ||
--- response_headers | ||
Location: https://test.com:1984/hello-https | ||
Location: https://test.com:9443/hello-https | ||
--- error_code: 301 | ||
--- no_error_log | ||
[error] | ||
|
@@ -1092,4 +1113,4 @@ Host: foo.com | |
X-Forwarded-Proto: http | ||
--- error_code: 301 | ||
--- response_headers | ||
Location: https://foo.com:1984/hello | ||
Location: https://foo.com:9443/hello |
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.
Personally, I feel that this code is too inelegant. Suggest:
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.
done