-
Notifications
You must be signed in to change notification settings - Fork 715
URLRewrite filter not working with websockets #2989
Copy link
Copy link
Closed
Labels
area/xds-translatorcherrypick/release-v1.0help wantedExtra attention is neededExtra attention is neededkind/bugSomething isn't workingSomething isn't working
Milestone
Description
Hi. The URLRewrite filter on the HTTPRoute, which works fine with regular HTTP requests, seems not to be working with websockets respectively fails when the websocket protocol upgrade is performed. I am not sure if this is a problem with envoy itself or with envoy gateway. But what I did is using a simple HTTP/WS echo server and the following HTTPRoute:
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: websocket-echo
namespace: default
spec:
hostnames:
- ws.example.com
parentRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: envoy-gateway-https
namespace: default
rules:
- backendRefs:
- group: ""
kind: Service
name: websocket-echo
port: 8080
weight: 1
filters:
- type: URLRewrite
urlRewrite:
path:
replaceFullPath: /
type: ReplaceFullPath
matches:
- path:
type: Exact
value: /echoWhile regular HTTP requests are echoed back just fine, above config results in error: Unexpected server response: 403 on the client side when trying to establish a websocket connection to https://ws.example.com/echo with e.g. wscat.
On the envoy proxy you can see the following log:
{
"start_time": "2024-03-20T12:26:30.465Z",
"method": "GET",
"x-envoy-origin-path": "/echo",
"protocol": "HTTP/1.1",
"response_code": "403",
"response_flags": "-",
"response_code_details": "upgrade_failed",
"connection_termination_details": "-",
"upstream_transport_failure_reason": "-",
"bytes_received": "0",
"bytes_sent": "0",
"duration": "0",
"x-envoy-upstream-service-time": "-",
"x-forwarded-for": "<redacted>",
"user-agent": "-",
"x-request-id": "e6e15a68-c012-482f-9fd9-f71b873e9e68",
":authority": "ws.example.com",
"upstream_host": "-",
"upstream_cluster": "httproute/default/websocket-echo/rule/0",
"upstream_local_address": "-",
"downstream_local_address": "<redacted>",
"downstream_remote_address": "<redacted>",
"requested_server_name": "-",
"route_name": "httproute/default/websocket-echo/rule/0/match/0/ws_example_com"
}If I remove the filter from the HTTPRoute websocket connections can be established without any problems.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area/xds-translatorcherrypick/release-v1.0help wantedExtra attention is neededExtra attention is neededkind/bugSomething isn't workingSomething isn't working