Skip to content
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: do not propagate well-known port number for xds portRedirect #3628

Merged
merged 2 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion internal/xds/translator/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,9 @@ func buildXdsRedirectAction(httpRoute *ir.HTTPRoute) *routev3.RedirectAction {
if redirection.Hostname != nil {
routeAction.HostRedirect = *redirection.Hostname
}
if redirection.Port != nil {
// Ignore the redirect port if it is a well-known port number, in order to
// prevent the port be added in the response's location header.
if redirection.Port != nil && *redirection.Port != 80 && *redirection.Port != 443 {
routeAction.PortRedirect = *redirection.Port
}
if redirection.StatusCode != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,32 @@ http:
redirect:
path:
prefixMatchReplace: /
- name: "redirect-route-4"
hostname: "*"
destination:
name: "redirect-route-dest"
settings:
- endpoints:
- host: "1.2.3.4"
port: 50000
redirect:
scheme: https
statusCode: 302
hostname: "redirected.com"
path:
prefixMatchReplace: /redirected
- name: "redirect-route-5"
hostname: "*"
destination:
name: "redirect-route-dest"
settings:
- endpoints:
- host: "1.2.3.4"
port: 50000
redirect:
scheme: https
statusCode: 302
port: 443
hostname: "redirected.com"
path:
prefixMatchReplace: /redirected
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,19 @@
pattern:
regex: ^/redirect/\/*
substitution: /
- match:
prefix: /
name: redirect-route-4
redirect:
hostRedirect: redirected.com
prefixRewrite: /redirected
responseCode: FOUND
schemeRedirect: https
- match:
prefix: /
name: redirect-route-5
redirect:
hostRedirect: redirected.com
prefixRewrite: /redirected
responseCode: FOUND
schemeRedirect: https