Skip to content

Commit 3d51933

Browse files
zetaabzirain
andauthored
fix: allow websockets in url rewrite (#3022)
allow websockets in url rewrite Signed-off-by: Jesse Haka <[email protected]> Co-authored-by: zirain <[email protected]>
1 parent a270dd8 commit 3d51933

File tree

5 files changed

+18
-0
lines changed

5 files changed

+18
-0
lines changed

internal/xds/translator/route.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ func buildXdsRoute(httpRoute *ir.HTTPRoute) (*routev3.Route, error) {
5959
routeAction.RequestMirrorPolicies = buildXdsRequestMirrorPolicies(httpRoute.Mirrors)
6060
}
6161

62+
if !httpRoute.IsHTTP2 {
63+
// Allow websocket upgrades for HTTP 1.1
64+
// Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism
65+
routeAction.UpgradeConfigs = []*routev3.RouteAction_UpgradeConfig{
66+
{
67+
UpgradeType: "websocket",
68+
},
69+
}
70+
}
71+
6272
router.Action = &routev3.Route_Route{Route: routeAction}
6373
default:
6474
var routeAction *routev3.RouteAction

internal/xds/translator/testdata/out/xds-ir/http-route-rewrite-root-path-url-prefix.routes.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@
1818
pattern:
1919
regex: ^/origin/\/*
2020
substitution: /
21+
upgradeConfigs:
22+
- upgradeType: websocket

internal/xds/translator/testdata/out/xds-ir/http-route-rewrite-url-fullpath.routes.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@
1414
pattern:
1515
regex: /.+
1616
substitution: /rewrite
17+
upgradeConfigs:
18+
- upgradeType: websocket

internal/xds/translator/testdata/out/xds-ir/http-route-rewrite-url-host.routes.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@
1717
cluster: rewrite-route-dest
1818
hostRewriteLiteral: 3.3.3.3
1919
prefixRewrite: /rewrite
20+
upgradeConfigs:
21+
- upgradeType: websocket

internal/xds/translator/testdata/out/xds-ir/http-route-rewrite-url-prefix.routes.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@
1515
route:
1616
cluster: rewrite-route-dest
1717
prefixRewrite: /rewrite
18+
upgradeConfigs:
19+
- upgradeType: websocket

0 commit comments

Comments
 (0)