Skip to content

fix: preserve reverse-proxy base path in SSH proxy URL#71

Merged
kaiitunnz merged 2 commits into
mainfrom
kaiitunnz/fix/ssh-proxy-url-base-path
Jun 13, 2026
Merged

fix: preserve reverse-proxy base path in SSH proxy URL#71
kaiitunnz merged 2 commits into
mainfrom
kaiitunnz/fix/ssh-proxy-url-base-path

Conversation

@kaiitunnz

@kaiitunnz kaiitunnz commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Purpose

When a FlowMesh server is deployed behind a reverse proxy that mounts it under a base path (e.g. reachable at example.com:8000/flowmesh), the SSH proxy connection instructions and the live proxy backend built a websocket URL with the base path stripped — wss://example.com:8000/api/v1/ssh/tasks/<id>/proxy instead of wss://example.com:8000/flowmesh/api/v1/ssh/tasks/<id>/proxy — so flowmesh ssh connect (and the copy-paste websocat command from flowmesh task watch) could not reach the proxy endpoint.

Changes

  • sdk/src/flowmesh/ssh.pyssh_proxy_url rebuilt the URL from urlsplit(base_url) keeping only the scheme and netloc, then hardcoded an absolute /api/v1/ssh/tasks/<id>/proxy path, discarding base.path. It now joins the configured base path with the API prefix ({base.path.rstrip('/')}{API_VERSION_PREFIX}/ssh/tasks/{task_id}/proxy), mirroring how _make_url composes REST URLs, and reuses the API_VERSION_PREFIX constant instead of re-hardcoding /api/v1. The http→ws / https→wss scheme conversion is unchanged.
  • tests/sdk/test_resource_helpers.py — regression coverage: root-mounted base URL (no double slash), base-path preservation (/flowmesh), http→ws / https→wss conversion, trailing-slash handling, and a proxy-mode ssh_connection_commands case asserting the embedded ProxyCommand URL carries the prefix.

Design

The single ssh_proxy_url helper feeds both user-visible paths — the printed ProxyCommand=websocat … instructions in flowmesh task watch and the live flowmesh ssh proxy backend used by flowmesh ssh connect — so the one-line fix corrects both. base.path.rstrip('/') yields "" for a root-mounted server (preserving the existing /api/v1/... output with no leading double slash) and /flowmesh for a base-path deployment, including the trailing-slash form.

Test Plan

uv run pytest tests/ --ignore=tests/worker/test_mp_executor_cleanup_gpu.py
uv run pre-commit run --all-files

Test Result

  • pytest tests/ --ignore=tests/worker/test_mp_executor_cleanup_gpu.py — all tests passed.
  • pre-commit run --all-files — black / isort / ruff / codespell pass.

Pre-submission Checklist
  • I have read the contribution guidelines.
  • I have run pre-commit run --all-files and fixed any issues.
  • I have added or updated tests covering my changes (if applicable).
  • I have verified that uv run pytest tests/ passes locally.
  • If I changed shared schemas or proto definitions, I have checked downstream compatibility across Server and Worker.
  • If I changed the SDK or CLI, I have verified the affected packages work.
  • If this is a breaking change, I have prefixed the PR title with [BREAKING] and described migration steps above.
  • I have updated documentation or config examples if user-facing behavior changed.

@kaiitunnz kaiitunnz changed the title fix(sdk): preserve reverse-proxy base path in SSH proxy URL fix: preserve reverse-proxy base path in SSH proxy URL Jun 12, 2026
ssh_proxy_url rebuilt the websocket URL from scheme and netloc only,
hardcoding an absolute /api/v1 path and discarding any base path. Behind
a reverse proxy mounted at e.g. /flowmesh, the prefix was dropped from
both the printed ProxyCommand instructions and the live `ssh proxy`
backend. Join the base path with the API prefix, consistent with
_make_url.

Signed-off-by: Noppanat Wadlom <noppanat.wad@gmail.com>
@kaiitunnz kaiitunnz force-pushed the kaiitunnz/fix/ssh-proxy-url-base-path branch from d500467 to fe57896 Compare June 13, 2026 11:58
Signed-off-by: Noppanat Wadlom <noppanat.wad@gmail.com>
@kaiitunnz kaiitunnz marked this pull request as ready for review June 13, 2026 12:50
@kaiitunnz kaiitunnz requested a review from timzsu June 13, 2026 12:50

@timzsu timzsu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@kaiitunnz kaiitunnz merged commit 98e3c97 into main Jun 13, 2026
11 of 13 checks passed
@kaiitunnz kaiitunnz deleted the kaiitunnz/fix/ssh-proxy-url-base-path branch June 13, 2026 13:09
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.

2 participants