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: allow websockets in url rewrite #3022

Merged
merged 3 commits into from
Mar 28, 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
10 changes: 10 additions & 0 deletions internal/xds/translator/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ func buildXdsRoute(httpRoute *ir.HTTPRoute) (*routev3.Route, error) {
routeAction.RequestMirrorPolicies = buildXdsRequestMirrorPolicies(httpRoute.Mirrors)
}

if !httpRoute.IsHTTP2 {
// Allow websocket upgrades for HTTP 1.1
// Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism
routeAction.UpgradeConfigs = []*routev3.RouteAction_UpgradeConfig{
{
UpgradeType: "websocket",
},
}
}

router.Action = &routev3.Route_Route{Route: routeAction}
default:
var routeAction *routev3.RouteAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
pattern:
regex: ^/origin/\/*
substitution: /
upgradeConfigs:
- upgradeType: websocket
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
pattern:
regex: /.+
substitution: /rewrite
upgradeConfigs:
- upgradeType: websocket
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@
cluster: rewrite-route-dest
hostRewriteLiteral: 3.3.3.3
prefixRewrite: /rewrite
upgradeConfigs:
- upgradeType: websocket
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
route:
cluster: rewrite-route-dest
prefixRewrite: /rewrite
upgradeConfigs:
- upgradeType: websocket
Loading