Skip to content

Support HTTPS gateway URLs for Tailscale Serve and reverse proxies - #20

Closed
shanselman with Copilot wants to merge 4 commits into
masterfrom
copilot/fix-openclaw-connection-issue
Closed

shanselman with Copilot wants to merge 4 commits into
masterfrom
copilot/fix-openclaw-connection-issue

Conversation

Copilot AI commented Feb 14, 2026 •

Copy link
Copy Markdown
Contributor

OpenClaw Windows Hub only accepted ws:// and wss:// URLs, preventing connections to gateways behind HTTPS reverse proxies (Tailscale Serve, nginx, etc.) where users have https://host.domain URLs.

Changes

  • Automatic protocol normalization in OpenClawGatewayClient constructor:

    // Normalizes user input to WebSocket protocols
    if (gatewayUrl.StartsWith("http://", StringComparison.OrdinalIgnoreCase))
        _gatewayUrl = gatewayUrl.Replace("http://", "ws://", StringComparison.OrdinalIgnoreCase);
    else if (gatewayUrl.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
        _gatewayUrl = gatewayUrl.Replace("https://", "wss://", StringComparison.OrdinalIgnoreCase);
  • Expanded URL validation in settings dialogs to accept http:// and https:// schemes (both WinForms and WinUI)

  • Updated UI placeholder text to show remote example: "ws://localhost:18789 or https://host.tailnet.ts.net"

Examples

Input:  https://mekbook.tail1e276.ts.net
Output: wss://mekbook.tail1e276.ts.net

Input:  http://localhost:18789
Output: ws://localhost:18789

Input:  wss://secure.example.com
Output: wss://secure.example.com (unchanged)

Backward compatible - existing ws:// and wss:// URLs pass through unchanged.

Original prompt

This section details on the original issue you should resolve

<issue_title>Can't connect to OpenClaw behind Tailscale Serve (hardcoded localhost/port, WS fails)</issue_title>
<issue_description>I have OpenClaw running on macOS and exposed to my tailnet using tailscale serve. The dashboard loads fine in a browser via the Serve URL, but the openclaw-windows-hub app cannot connect, even when I try wss://.

This looks like the Windows Hub assumes a local gateway (ws://localhost:18789) and/or assumes it can reach the gateway on the backend port, which breaks when the gateway is behind Tailscale Serve (HTTPS on 443 proxying to 127.0.0.1:18789).

Environment

  • Host: macOS (OpenClaw gateway running locally on 127.0.0.1:18789)
  • Exposure: Tailscale Serve (tailnet only)
  • Client: Windows 11, same tailnet, using openclaw-windows-hub

Tailscale Serve status (host)

tailscale serve status shows:

https://mekbook.tail1e276.ts.net (tailnet only)
|-- / proxy http://127.0.0.1:18789

What works

  • From Windows browser:
    • https://mekbook.tail1e276.ts.net/ loads the OpenClaw dashboard successfully

What doesn't work

  • From Windows browser:
    • WebSocket functionality in the dashboard does not work (UI loads but the app is non-functional because WS doesn't connect)
  • From openclaw-windows-hub:
    • Cannot connect to the gateway via the Serve hostname
    • Trying ws://mekbook.tail1e276.ts.net:18789 fails (Serve does not expose the backend port)
    • Trying wss://mekbook.tail1e276.ts.net/... also fails (likely because the app assumes localhost/port/path and/or does not support remote HTTPS/WSS properly)

Expected behavior

Windows Hub should be able to connect to a gateway exposed via Tailscale Serve by using:

  • https://<host>.tail*.ts.net/ for the base URL, and
  • wss://<host>.tail*.ts.net/<ws-path> for WebSockets,
    without assuming localhost or :18789.

Suspected root cause

  • Windows Hub hardcodes or defaults to ws://localhost:18789 (or otherwise assumes local gateway semantics)
  • No proper support for remote https:///wss:// gateway URLs
  • Possibly constructs WS URLs incorrectly when the gateway is accessed via HTTPS (mixed content, wrong port, wrong origin)

Suggested fix

  • Allow configuring a remote base URL (https://...) and derive the WS URL from it:
    • Prefer same-origin wss:// when base is HTTPS
    • Do not append :18789 when using Tailscale Serve (Serve is on 443 and proxies internally)
  • Improve logging/error reporting for the WS connection attempt (show the computed WS URL and the close reason)

Repro steps

  1. Run OpenClaw gateway on macOS bound to 127.0.0.1:18789
  2. Expose with tailscale serve:
    • https://<host>.tail*.ts.net/ -> http://127.0.0.1:18789
  3. On Windows (same tailnet), open https://<host>.tail*.ts.net/ (dashboard loads)
  4. Try using openclaw-windows-hub to connect to that gateway (fails; WS doesn't connect)</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix OpenClaw connection issue behind Tailscale Serve Support HTTPS gateway URLs for Tailscale Serve and reverse proxies Feb 14, 2026
Copilot AI requested a review from shanselman February 14, 2026 04:18
@shanselman

Copy link
Copy Markdown
Collaborator

Closing as superseded. Issue #19 is fixed directly on master in f78d2ed with shared URL normalization and test coverage.

@shanselman shanselman closed this Feb 17, 2026
@shanselman
shanselman deleted the copilot/fix-openclaw-connection-issue branch March 17, 2026 05:01
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.

Can't connect to OpenClaw behind Tailscale Serve (hardcoded localhost/port, WS fails)

2 participants