DEV Community

啦啦啦种太阳
啦啦啦种太阳

Posted on Originally published at dsh-plugin.com

DeepSeek Harness behind a reverse proxy: why --public-url alone still gets a 403

You put the DeepSeek Harness Web UI behind a reverse proxy, set --public-url, and the page loads. Then every API call returns a 403. The URL is right, the proxy forwards traffic, and TLS works. What is missing?

Usually, nothing is broken. One setting is being asked to do a job it does not do. --public-url advertises an address; it does not trust that address. --trusted-host determines which browser authorities are accepted, while the proxy handles its own host, path, cookie, and upgrade responsibilities.

This post starts with that 403, clarifies what each setting controls, walks through the proxy contract, and ends with TLS and the safety limits.

Reverse proxy publication and host trust flow

Why a correct URL can still produce 403

The host fence allows loopback, the listener's bound address, and authorities explicitly named by --trusted-host. Advertising https://app.example/ui/ alone does not add app.example to that set. A proxy can forward traffic correctly while every API call is rejected because the browser-visible authority is not trusted.

Compare three values: the actual browser URL, the Host forwarded by the proxy, and the configured trusted authority. An entry without a port matches any port, which can help with tunnels that change ports. Add only authorities intended for the deployment. TLS termination does not change the host check. A certificate identifies the server to the browser; it does not identify the browser to DSH.

Treat a 403 as evidence to investigate, not proof that this particular check failed. The web-server reference also describes a 403 for traversal outside the frontend distribution root. Record the requested path and which layer returned the response. Check the mount rewrite and the authentication flow as well as the authority. Do not add unrelated hosts or change a security setting just because the status code looks familiar.

What each setting actually owns

The Web profile normally listens on loopback, so a browser on another machine needs a route to reach it. (If you are still deciding which profile to run, see Which DeepSeek Harness profile should you use?.) The public deployment guide divides the work among three parts: the proxy owns the external connection, DSH advertises the URL, and the Connection layer decides which browser authority it accepts. The web-server reference describes the HTTP carrier and its separate authentication layer.

Component Responsibility Does not establish
--public-url Advertises the browser-facing root and optional mount Trust or authentication
--trusted-host Adds an accepted browser authority A public route or TLS
Reverse proxy Terminates or forwards the connection and translates paths DSH user authentication
Startup token and signed cookie Authenticate the browser session Network isolation of the listener

The documented command sets both flags:

dsh --profile web --public-url https://app.example/ui/ --trusted-host app.example
Enter fullscreen mode Exit fullscreen mode

Replace the example hostname with your actual browser-facing authority. --public-url accepts HTTP or HTTPS roots and normalizes the trailing slash. It provides the startup URL that is printed and opened, DSH_WEB_URL, and the Web GUI URL in the agent runtime context. The backend still serves routes from the origin root; the flag does not make it aware of /ui/.

This is the inbound proxy in front of the Web UI. Routing the harness's outbound model requests through a proxy is a different problem, covered in Fix DeepSeek Harness model requests behind a proxy.

The proxy contract

  1. Keep the backend listener reachable only from the trusted proxy or network. Neither the advertised URL nor the host fence protects the listening port itself.
  2. Preserve the browser-visible Host header when forwarding. Replacing it with the backend address changes the authority the fence sees.
  3. Strip the external prefix before forwarding: /ui/api/... must reach the backend as /api/.... Forward WebSocket upgrades with their Upgrade and Connection headers as well.
  4. Redirect the bare mount /ui to /ui/. Only the slash-terminated entry exchanges the startup token for a session cookie. A browser with that cookie can obtain the document from that entry or /ui/index.html.
  5. Rewrite the backend cookie path to the external mount. If the backend uses plain HTTP, add Secure on the HTTPS-facing proxy; if the backend itself serves TLS, its cookie already has that attribute.
  6. Open the advertised URL and check an API request and a WebSocket connection. Keep the full startup URL private: it contains a process credential.

This list is a contract for the proxy, not a ready configuration for any particular proxy product; the exact directives depend on the product. Check the browser's network panel and the proxy logs, without copying the token or cookie into a public issue. Keeping the external request and the request received by the listener apart makes path and authority errors easier to isolate.

Testing the full request path

Start at the browser-visible URL and follow one request through each layer. Note the browser authority and external path, then compare them with the Host and path received at the backend. For a mounted deployment, a correct external /ui/api/... request must become a backend /api/... request. If the backend receives the prefix unchanged, the advertised URL can still look correct while routes fail. If the proxy rewrites the host, the backend can see a different authority from the one the browser used. These are two independent observations, so record both.

Next, check the entry and cookie exchange. The guide distinguishes /ui/ from the bare /ui because the backend cannot reconstruct a prefix stripped by the proxy. Verify that the browser reaches the slash-terminated entry, then check whether later requests carry the cookie at the rewritten path. Use the browser's own tools without sharing credential values. If the page is served but a later API request is rejected, keep the exact status and path: the failure can happen after the document was delivered.

Finally, check the WebSocket upgrade. Forwarding ordinary requests alone does not meet the guide's requirements. A useful diagnostic note states whether document loading, an API request and the upgrade each succeeded, and whether the listener or the proxy produced each response. Repeat the same checks after every configuration change so the before-and-after evidence stays comparable.

Where TLS should terminate

The public guide supports TLS at the proxy, at the listener, or both. HTTPS at the proxy protects the browser-to-proxy segment; whether the next segment is encrypted depends on the listener. A browser-facing HTTP URL exposes the startup token in plaintext. A private backend network is a deployment responsibility, not a consequence of the URL flag.

For native listener TLS, the guide documents --tls-cert and --tls-key with a full certificate chain and an unencrypted PEM private key. Paths resolve relative to the process working directory. The listener reads them once, so replace the files and reload the listener or restart the process to pick up a certificate change. Invalid or missing material prevents startup instead of silently falling back to HTTP. The certificate must match the hostname or IP the browser uses and be trusted by that browser.

A TLS proxy and a TLS listener protect different segments. A valid browser-to-proxy certificate says nothing, by itself, about how the proxy reaches the backend. Native TLS at the listener does not configure the browser-facing proxy or its cookie rewrite. Draw the actual network path, identify who can reach each listener, and choose a control for each segment. If the proxy and backend share a host, loopback helps restrict reachability, but access control for the host remains an operational responsibility.

The WebServer carrier rejects an unspecified bind address instead of listening on every interface. The Web profile defaults to loopback, and a concrete non-loopback address can serve traffic on the network associated with that interface. Changing that address has a different effect from adding a trusted browser authority. Keep these choices visible in deployment notes so future operators can distinguish an announcement, a host check, and an actual listening socket.

Limits and safety boundaries

The startup link contains a credential. Share it only with intended users, keep it out of public tickets, and do not mistake a working TLS connection for access control. The proxy must protect both the URL and the cookies while keeping the required host, path and upgrade behavior. Cookie scope matters when several applications share a hostname: rewriting the path is part of the deployment, not a cosmetic change.

Quick triage:

  • The page loads but API calls fail: identify the failing path and response before changing settings.
  • Only the bare mount fails: verify the slash redirect and the token exchange.
  • A TLS listener fails to start: inspect the certificate and key; it will not fall back to HTTP.

The official documentation does not specify one universal proxy configuration, so test the complete chain in your own environment. For broader questions, see the DSH Plugin FAQ.

Terms used above

  • Authority: the host and optional port used by the browser and checked by the host fence.
  • Mount prefix: the external path, such as /ui/, removed before requests reach origin-root backend routes.
  • Startup token: the process credential in the printed URL, exchanged at the entry for a signed browser session cookie.
  • TLS termination: the point where an HTTPS connection is decrypted; a separate proxy-to-listener connection may have different protection.
  • Host fence: the check that restricts accepted browser authorities; it is separate from browser authentication.

Originally published at https://dsh-plugin.com/blog/public-url-trusted-host-reverse-proxy

Top comments (0)