Skip to content

feat(client): add transport.websocketPath option for custom websocket handshake path#5389

Open
6rock wants to merge 1 commit into
fatedier:devfrom
6rock:feat/websocket-path
Open

feat(client): add transport.websocketPath option for custom websocket handshake path#5389
6rock wants to merge 1 commit into
fatedier:devfrom
6rock:feat/websocket-path

Conversation

@6rock

@6rock 6rock commented Jul 1, 2026

Copy link
Copy Markdown

WHY

Closes #5388

When transport.protocol is websocket or wss, frpc always performs the websocket handshake on a hard-coded path /~!frp (pkg/util/net/websocket.go), with no way to configure it. This makes it hard to place frps behind a reverse proxy (e.g. nginx) that routes traffic by path — for example sharing port 443 with other services, or running multiple frps instances behind a single entrypoint.

This PR adds a client-side transport.websocketPath option:

  • Defaults to /~!frp when empty — fully backward compatible, existing configs are unaffected.
  • When set (must start with /), the client uses it for the websocket/wss handshake.
  • The server needs no changes: the reverse proxy is responsible for forwarding the custom path back to frps' default /~!frp.

Example:

transport.protocol = "wss"
transport.websocketPath = "/frp"

nginx then matches location /frp, rewrites it to /~!frp, and proxies to frps.

Changes

  • Add WebsocketPath to the v1 ClientTransportConfig and the legacy client config (with legacy→v1 conversion).
  • Thread the path through DialHookWebsocket, defaulting to /~!frp when empty (consistent with the existing empty-parameter defaulting in that function).
  • Validate that the path starts with / (both v1 and legacy validation).
  • Update frpc_full_example.toml, the legacy ini example, and Release.md.

The change is client-side only; go build / go vet and pkg/config/... tests pass.

@kilo-code-bot

kilo-code-bot Bot commented Jul 1, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (9 files)
  • Release.md
  • client/connector.go
  • conf/frpc_full_example.toml
  • conf/legacy/frpc_legacy_full.ini
  • pkg/config/legacy/client.go
  • pkg/config/legacy/conversion.go
  • pkg/config/v1/client.go
  • pkg/config/v1/validation/client.go
  • pkg/util/net/dial.go

Reviewed by gpt-5.5-20260423 · Input: 73K · Output: 5.1K · Cached: 338.2K

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Support custom websocket handshake path (transport.websocketPath) for reverse-proxy routing

2 participants