Skip to content

Commit

Permalink
fix: allow websockets in url rewrite (envoyproxy#3022)
Browse files Browse the repository at this point in the history
allow websockets in url rewrite

Signed-off-by: Jesse Haka <[email protected]>
Co-authored-by: zirain <[email protected]>
  • Loading branch information
zetaab and zirain authored Mar 28, 2024
1 parent a270dd8 commit 3d51933
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
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

0 comments on commit 3d51933

Please sign in to comment.