Skip to content

ws

Converts a WebSocket request into a new ws request (the server will receive the converted WebSocket URL).

Only supports WebSocket requests ws[s]://domain[:port]/[path][?query]. Transformation tunneling and plain HTTP/HTTPS are not supported.

Rule Syntax

txt
pattern ws://value [filters...]
ParametersDescriptionDetailed Documentation
patternExpression to match WebSocket request URLsMatch Pattern Documentation
valueTarget URL format: domain[:port]/[path][?query]
⚠️ Loading data from files/remote URLs is not supported
Operation Instruction Documentation
filtersOptional filters, supporting matching:
• Request URL/Method/Headers/Content
• Response Status Code/Headers
Filters Documentation

WebSocket Transformation

txt
ws://www.example.com/path1 ws://www.test.com/path/xxx
wss://www.example.com/path2 ws://www.abc.com/path3/yyy
  1. Automatic path concatenation:
    Original requestConversion result (URL received by the server)
    ws://www.example.com/path1ws://www.test.com/path/xxx
    ws://www.example.com/path1/a/b/c?queryws://www.test.com/path/xxx/a/b/c?query
    wss://www.example.com/path2ws://www.abc.com/path3/yyy
    wss://www.example.com/path2/a/b/c?queryws://www.abc.com/path3/yyy/a/b/c?query
  2. Disable path concatenation: Use < > or () to wrap the path.
    txt
    www.example.com/path1 ws://<www.test.com/path/xxx>
    # www.example.com/path1 ws://(www.test.com/path/xxx)
    Original RequestConversion Result (URL Received by the Server)
    [wss/ws]://www.example.com/path/x/y/zws://www.test.com/path/xxx

Only supports forwarding WebSocket requests; other requests match the ws protocol. Result:

  • Tunnel Proxy: Ignore matches
  • Normal HTTP/HTTPS Request: Returns 502