Files
coder/docs/admin/networking/index.md
T
Nick Vigilante d40e24cf7d docs: nest the CLI reference by subcommand (#29956)
## Summary

Nests the CLI reference by subcommand so the Command Line sidebar
collapses from 156 flat entries to 49 top-level verbs.
Each page's URL follows the invocation, its page title is the full
command as inline code, and its sidebar label is only its own verb as
inline code.

| | Before | After |
| --- | --- | --- |
| File | `docs/reference/cli/oauth2-provider_dcr_disable.md` |
`docs/reference/cli/oauth2-provider/dcr/disable.md` |
| URL | `/reference/cli/oauth2-provider_dcr_disable` |
`/reference/cli/oauth2-provider/dcr/disable` |
| Page title (front matter) | `oauth2-provider dcr disable` | `` `coder
oauth2-provider dcr disable` `` |
| Sidebar label (manifest) | `oauth2-provider dcr disable` | ``
`disable` `` |

Resolves DOCS-140 (coder/coder half). Also fixes the Makefile part of
DOCS-1073 / DOCS-912, which this change depends on.

## Changes

- `scripts/clidocgen`: pages nest by command path. A command with
visible subcommands becomes its directory's `index.md`, so
`oauth2-provider/index.md` and `oauth2-provider/dcr/index.md` sit above
`oauth2-provider/dcr/disable.md`. Subcommand table links are relative to
the parent page.
- `scripts/clidocgen`: the manifest "Command Line" section is built from
the command tree (nested, sorted by name, hidden commands skipped)
instead of a flat list. The redundant `coder` child that pointed back at
`reference/cli/index.md` is gone.
- `Makefile`: the CLI rule now replaces `docs/reference/cli/` wholesale,
so stale pages get removed. The manifest rule now runs `clidocgen
-manifest-only` on top of the API staging manifest, so the CLI nav is
generated instead of edited by hand. As a result, the nine pages that
had no nav entry (`ai-gateway*`, `secret enable/disable`, `server
fix-oidc-links`) now have one.
- `scripts/configdocgen` and 48 prose pages: links point at the new
paths (for example `reference/cli/server.md` is now
`reference/cli/server/index.md`).

## How to review/QA this PR

- `docs/reference/cli/**/*` (approximately 190 pages): Each of these
pages are generated automatically. Some pages appear deleted, and some
pages appear new. Every deleted page corresponds to a new page somewhere
else, so no information is being deleted. The docs in this section
should adhere to the following, so a test in the build preview for each
of these items should be satisfactory:
- [ ] Each subcommand of a command gets nested as a child instead of
being displayed as a flat list.
  - [ ] Each parent command is stored in an `index.md` file.
- [ ] The title of each page inside the page should now feature the full
`coder XYZ` command.
- [ ] The title of each page inside the page should now be formatted as
inline code.
- [ ] The title of each page in the sidebar should be the most granular
subcommand of the whole command string (if the page's title is `coder
ai-gateway keys create`, the sidebar label is `create`).
- [ ] The title of each page in the sidebar should now be formatted as
inline code.
  - [ ] The page slug for each page is now the most granular subcommand.
  - [ ] All links now point to the correct page.
- `docs/manifest.json`: The changes here reflect the updated structure
of the `docs/reference/cli` section.
- `docs/**/*.md` outside of `docs/reference/cli/**/*` (approximately 50
pages): The extent of the changes in these pages are just updating the
paths to point to the new page locations.
- [ ] The links on the page all point to the correct new path in
`docs/reference/cli`.
- `scripts/clidocgen` (4 files): This is the Go code responsible for
generating everything inside of `docs/reference/cli/**/*`. A typical
code review here should be satisfactory.
- `scripts/configdocgen` (2 files): these two files just have updates to
the raw `.md` path used by `docs/admin/setup/configuration-reference.md`
and updates the tests to reflect that.
- `Makefile`: This updates the `make` targets for generating the CLI
docs to fit the new structure.

## Merge ordering

Without the renderer PRs deployed, both docs sites show literal
backticks in titles and sidebar labels. Without the redirects, the old
flat URLs return 404.

1. Deploy before merging this PR: coder/docs-engine#176 (beta-docs
renders these titles as inline code) and coder/coder.com#1111 (classic
docs renders them as inline code). Both are safe to ship first, because
titles without backticks render as before.
2. Merge this PR.
3. Merge coder/coder.com#1112 (redirects from the old flat URLs) only
once this content reaches the mainline release branch that serves
unversioned `/docs`.

## Testing

- `go test ./scripts/clidocgen/ ./scripts/configdocgen/
./scripts/docshtmlcheck/`: pass. New tests cover page paths, subcommand
links, the nested manifest, and front matter quoting.
- `make docs/reference/cli/index.md docs/manifest.json
docs/admin/setup/configuration-reference.md`, then a forced rerun: the
second run produced no diff.
- Checked the manifest: all 164 CLI entries resolve to a file, no page
is missing a nav entry, and everything outside "Command Line" is
byte-identical.
- Relative `.md` links across `docs/`: 0 broken, same as `main`.
- `make pre-commit` and `make pre-push`: pass. On earlier pre-push
attempts, different unrelated vitest files timed out under host load.
Those files pass when run alone, and the final push passed with
`PARALLEL_JOBS=1`.

<details>
<summary>Implementation plan and decision log</summary>

**Goal (from DOCS-140 and the requester):** URLs follow the command
hierarchy. Pages are titled with the full command, and sidebar entries
with the last verb only. Both are formatted as inline code.

**Contract with the renderers:** a title wrapped entirely in one pair of
backticks (``^`[^`]+`$``) renders as inline code. Plain-text consumers
(`<title>`, meta, search, llms corpus) strip the backticks. Page title
comes from front matter `title`, and the sidebar label from the manifest
node `title`.

**Decisions**

- A parent command is `dir/index.md` rather than a sibling `dir.md`. The
root CLI page is already `index.md`, and both docs-engine and the legacy
coder.com renderer map `x/index.md` to `/x`.
- The manifest is built from the command tree, not from the written
files, so ordering is deterministic and the nesting matches the pages
exactly.
- The manifest discard bug (DOCS-1073 item 1) is fixed here, because
without that fix the generated nested manifest would never reach the
tree. DOCS-1073 items 2 through 4 (a prose fix and a hidden-command
policy) are out of scope.
- `-manifest-only` keeps the existing parallel `make gen` layout: the
API rule still owns `_gen/manifest-staging.json`, and CLI regeneration
doesn't retrigger swag.
- The renderer and redirect work lives in the companion PRs in
coder/docs-engine and coder/coder.com. It is linked above and not
duplicated here.

</details>

---

> [!NOTE]
> Generated by Coder Agents on behalf of @nickvigilante.
2026-09-28 15:44:10 -04:00

11 KiB
Raw Blame History

title
title
Networking

Coder's network topology has three types of nodes: workspaces, the control plane, and users.

The control plane must have an inbound address reachable by users and workspaces, but otherwise, all topologies just work with Coder.

When possible, we establish direct connections between users and workspaces. Direct connections are as fast as connecting to the workspace outside of Coder. When NAT traversal fails, connections are relayed through the control plane. All user-workspace connections are end-to-end encrypted.

Tailscale's open source backs our websocket/HTTPS networking logic.

Requirements

In order for clients and workspaces to be able to connect:

Note

We strongly recommend that clients connect to Coder and their workspaces over a good quality, broadband network connection. The following are minimum requirements:

  • better than 400 ms round-trip latency to the control plane and to their workspace
  • better than 0.5% random packet loss
  • All clients and agents must be able to establish a connection to the control plane (CODER_ACCESS_URL) over HTTP/HTTPS.
  • Any reverse proxy or ingress between the Coder control plane and clients/agents must support WebSockets.

In order for clients to be able to establish direct connections:

Note

Direct connections via the web browser are not supported. To improve latency for browser-based applications running inside Coder workspaces in regions far from the Coder control plane, consider deploying one or more workspace proxies.

  • The client is connecting using the CLI (e.g. coder ssh or coder port-forward). Note that the VSCode extension and JetBrains Plugin, and ssh coder.<workspace> all utilize the CLI to establish a workspace connection.
  • Either the client or workspace agent are able to discover a reachable ip:port of their counterpart. If the agent and client are able to communicate with each other using their locally assigned IP addresses, then a direct connection can be established immediately. Otherwise, the client and agent will contact the configured STUN servers to try and determine which ip:port can be used to communicate with their counterpart. See STUN and NAT for more details on how this process works.
  • All outbound UDP traffic must be allowed for both the client and the agent on all ports to each others' respective networks.
    • To establish a direct connection, both agent and client use STUN. This involves sending UDP packets outbound on udp/3478 to the configured STUN server. If either the agent or the client are unable to send and receive UDP packets to a STUN server, then direct connections will not be possible.
    • Both agents and clients will then establish a WireGuard️ tunnel and send UDP traffic on ephemeral (high) ports. If a firewall between the client and the agent blocks this UDP traffic, direct connections will not be possible.

Control plane

Workspaces connect to the control plane via its external address, set by ACCESS_URL. There must not be a NAT between workspaces and the control plane.

Users connect to the control plane's dashboard and API through its ACCESS_URL as well. There must not be a NAT between users and the control plane.

Template admins can overwrite the site-wide access URL at the template level by leveraging the url argument when defining the Coder provider:

provider "coder" {
  url = "https://coder.namespace.svc.cluster.local"
}

This is useful when debugging connectivity issues between the workspace agent and the control plane.

Web Apps

The control plane relays dashboard-initiated connections between the user and the workspace. Web terminal <-> workspace connections are an exception and may be direct.

In general, port forwarded web apps are faster than dashboard-accessed web apps.

🌎 Geo-distribution

Direct connections

Direct connections are a straight line between the user and workspace, so there is no special geo-distribution configuration. To speed up direct connections, move the user and workspace closer together.

Establishing a direct connection can be an involved process because both the client and workspace agent will likely be behind at least one level of NAT, meaning that we need to use STUN to learn the IP address and port under which the client and agent can both contact each other. See STUN and NAT for more information on how this process works.

If a direct connection is not available (e.g. client or server is behind NAT), Coder will use a relayed connection. By default, Coder uses Google's public STUN server, but this can be disabled or changed for Air-gapped deployments.

Relayed connections

By default, your control plane also runs a built-in DERP relay which can be used for both public and Air-gapped deployments.

However, Tailscale maintains a global fleet of DERP relays intended for their product, and has allowed Coder to access and use them. You can launch coder server with Tailscale's DERPs like so:

coder server --derp-config-url https://controlplane.tailscale.com/derpmap/default

Custom Relays

If you want lower latency than what Tailscale offers or want additional DERP relays for air-gapped deployments, you may run custom DERP servers. Refer to Tailscale's documentation to learn how to set them up.

After you have custom DERP servers, you can launch Coder with them like so:

# derpmap.json
{
  "Regions": {
    "1": {
      "RegionID": 1,
      "RegionCode": "myderp",
      "RegionName": "My DERP",
      "Nodes": [
        {
          "Name": "1",
          "RegionID": 1,
          "HostName": "your-hostname.com"
        }
      ]
    }
  }
}
coder server --derp-config-path derpmap.json

Dashboard connections

The dashboard (and web apps opened through the dashboard) are served from the control plane, so they can only be geo-distributed with High Availability mode in our Premium Edition. Reach out to Sales to learn more.

Browser-only connections

Note

Browser-only connections is a Premium feature. Learn more.

Some Coder deployments require that all access is through the browser to comply with security policies. In these cases, pass the --browser-only flag to coder server or set CODER_BROWSER_ONLY=true.

With browser-only connections, developers can only connect to their workspaces via the web terminal and web IDEs.

Workspace Proxies

Note

Workspace proxies are a Premium feature. Learn more.

Workspace proxies are a Coder Premium feature that allows you to provide low-latency browser experiences for geo-distributed teams.

To learn more, see Workspace Proxies.

Latency

Coder measures and reports several types of latency, providing insights into the performance of your deployment. Understanding these metrics can help you diagnose issues and optimize the user experience.

There are three main types of latency metrics for your Coder deployment:

  • Dashboard-to-server latency:

    The Coder UI measures round-trip time to the control plane or workspace proxy using built-in browser timing capabilities.

    This appears in the user interface next to your username, showing how responsive the dashboard is.

  • Workspace connection latency:

    The latency shown on the workspace dashboard measures the round-trip time between the workspace agent and its DERP relay server.

    This metric is displayed in milliseconds on the workspace dashboard and specifically shows the agent-to-relay latency, not direct P2P connections.

    To estimate the total end-to-end latency experienced by a user, add the dashboard-to-server latency to this agent-to-relay latency.

  • Database latency:

    For administrators, Coder monitors and reports database query performance in the health dashboard.

How latency is classified

Latency measurements are color-coded in the dashboard:

  • Green (<150 ms): Good performance.
  • Yellow (150-300 ms): Moderate latency that might affect user experience.
  • Red (>300 ms): High latency that will noticeably affect user experience.

View latency information

  • Dashboard: The global latency indicator appears in the top navigation bar.
  • Workspace list: Each workspace shows its connection latency.
  • Health dashboard: Administrators can view advanced metrics including database latency.
  • CLI: Use coder ping <workspace> to measure and analyze latency from the command line.

Factors that affect latency

  • Geographic distance: Physical distance between users, the control plane, and workspaces.
  • Network connectivity: Quality of internet connections and routing.
  • Infrastructure: Cloud provider regions and network optimization.
  • P2P connectivity: Whether direct connections can be established or relays are needed.

How to optimize latency

To improve latency and user experience:

  • Deploy workspace proxies: Place proxies in regions closer to users, connecting back to your single control plane deployment.
  • Use P2P connections: Ensure network configurations permit direct connections.
  • Strategic placement: Deploy your control plane in a region where most users work.
  • Network configuration: Optimize routing between users and workspaces.
  • Check firewall rules: Ensure they don't block necessary Coder connections.

For help troubleshooting connection issues, including latency problems, refer to the networking troubleshooting guide.

External Network Access

By default, Coder will access some external network endpoints in order to download dependencies and send usage data. However, all of these features can be disabled. Learn how to configure Coder for air-gapped environments.

Up next