Repository navigation
docs: add guide for self-hosting a STUN server - #31996
Merged
Merged
Conversation
Adds a how-to for running coturn or Tailscale's stund as a self-hosted STUN server and pointing CODER_DERP_SERVER_STUN_ADDRESSES at it, and links it from the STUN, networking, and air-gapped pages.
nickvigilante
marked this pull request as ready for review
November 10, 2026 16:10
spikecurtis
reviewed
Nov 10, 2026
stund has no published releases, so readers would build an unpinned binary from Tailscale's main branch. coturn ships as distribution packages and an official container image, so the guide covers only it. The built-in relay isn't a prerequisite for self-hosted STUN. Only the CODER_DERP_SERVER_STUN_ADDRESSES setting depends on it, so the Configure Coder note now says that and describes the STUN-only regions to add to a custom relay map. The netcheck jq filter now selects STUN-only nodes instead of generated coder_stun region codes, so it also lists STUN servers from a custom relay map. Also applies review wording for the NAT hairpinning and reverse proxy bullets.
The built-in relay is optional for self-hosted STUN. It's needed only for CODER_DERP_SERVER_STUN_ADDRESSES, which Coder ignores when CODER_DERP_SERVER_ENABLE=false. Move the custom relay map guidance into its own section that says so, and note that a relay map with only STUN-only nodes fails startup (tailnet.NewDERPMap requires a relay node). Also scopes the apt-get step and config path to Debian and Ubuntu, mentions installing jq before the verify step, and fixes a run-on in the air-gapped STUN row.
Contributor
Documentation CheckBlocking
Findings for agents- id: structure-1
persona: structure
class: rule
blocking: true
file: docs/admin/networking/self-hosted-stun.md
line: 46
quote: " ```text"
evidence:
- docs/.style/style-guide/formatting.md#code-blocks-with-language-fences
rule: docs/.style/style-guide/formatting.md#code-blocks-with-language-fences
problem: "The coturn config fence uses `text`, but the canonical tag for a block with no syntax to highlight is `txt`."
fix: "Change the fence to ```txt."
verified: true
- id: structure-2
persona: structure
class: rule
blocking: true
file: docs/admin/networking/self-hosted-stun.md
line: 179
quote: " ```text"
evidence:
- docs/.style/style-guide/formatting.md#code-blocks-with-language-fences
rule: docs/.style/style-guide/formatting.md#code-blocks-with-language-fences
problem: "The `coder ping` output block is tagged `text`; the style guide uses `txt` for command output shown on its own."
fix: "Change the fence to ```txt."
verified: true
- id: consistency-1
persona: consistency
class: rule
blocking: true
file: docs/admin/networking/self-hosted-stun.md
line: 132
quote: "Coder's built-in relay is optional for self-hosted STUN."
evidence:
- docs/reference/cli/server/index.md#--derp-server-enable
- docs/admin/setup/configuration-reference.md
- docs/install/prepare/airgap.md
rule: docs/.style/style-guide/word-choice.md#one-term-per-concept
problem: ""Coder's built-in relay" names the DERP relay server differently from the rest of the docs, which call it the "embedded DERP relay server" or "built-in DERP relay"."
fix: "Use "built-in DERP relay" at lines 132, 133, and 135."
verified: true
- id: consistency-2
persona: consistency
class: suggestion
blocking: false
file: docs/admin/networking/self-hosted-stun.md
line: 135
quote: "Without the built-in relay, add your STUN servers to the [custom relay map](./index.md#custom-relays) that you provide with `CODER_DERP_CONFIG_URL` or `CODER_DERP_CONFIG_PATH`:"
evidence:
- docs/reference/cli/server/index.md#--derp-config-url
rule: docs/.style/style-guide/word-choice.md#one-term-per-concept
problem: "This page calls the JSON artifact a "custom relay map", but the reference docs call the same thing a "DERP mapping"."
fix: "Align the term with the canonical "DERP map"/"DERP mapping"."
verified: true
- id: consistency-3
persona: consistency
class: suggestion
blocking: false
file: docs/admin/networking/self-hosted-stun.md
line: 127
quote: "- Run two or more STUN servers on separate hosts."
evidence:
- docs/reference/cli/server/index.md#--derp-server-stun-addresses
rule: null
problem: ""Run two or more STUN servers" diverges from the canonical wording "at least two"."
fix: "Use "Run at least two STUN servers on separate hosts.""
verified: true
- id: consistency-4
persona: consistency
class: suggestion
blocking: false
file: docs/admin/networking/self-hosted-stun.md
line: 103
quote: "Set [`CODER_DERP_SERVER_STUN_ADDRESSES`](../../reference/cli/server/index.md#--derp-server-stun-addresses) to a comma-separated list of your STUN servers, in `host:port` form:"
evidence:
- cli/server.go:693
- tailnet/derpmap.go:72
rule: null
problem: "The "Configure Coder" section sets `CODER_DERP_SERVER_STUN_ADDRESSES` without noting Coder ignores it when `CODER_DERP_SERVER_ENABLE=false`."
fix: "Add a pointer to `./index.md#custom-relays` here."
verified: true
- id: coverage-1
persona: coverage
class: suggestion
blocking: false
file: docs/admin/networking/self-hosted-stun.md
line: 135
quote: "Without the built-in relay, add your STUN servers to the [custom relay map](./index.md#custom-relays) that you provide with `CODER_DERP_CONFIG_URL` or `CODER_DERP_CONFIG_PATH`:"
evidence:
- docs/admin/networking/index.md#custom-relays
rule: null
problem: "The "Use a custom relay map" section links to `index.md#custom-relays`, whose example shows only a relay node with no `STUNOnly`/`STUNPort`, so the reader cannot compose the map."
fix: "Extend the `index.md` example to show a STUN-only region."
verified: true
- id: accuracy-1
persona: accuracy
class: suggestion
blocking: false
file: docs/admin/networking/self-hosted-stun.md
line: 127
quote: "- Run two or more STUN servers on separate hosts."
evidence:
- tailnet/derpmap.go:21-54
rule: null
problem: ""Direct connections keep working if one server goes down" is not pinned by a test."
fix: "Add a test dropping one STUN region and asserting the remaining region still probes, or qualify the claim."
verified: true
- id: accuracy-2
persona: accuracy
class: suggestion
blocking: false
file: docs/admin/networking/self-hosted-stun.md
line: 119
quote: "Running workspaces pick up the new STUN servers without a restart."
evidence:
- workspaceagents.go:1257
- agent/agent_test.go:3628
rule: null
problem: ""Running workspaces pick up the new STUN servers without a restart" is not pinned by a test of the coderd `/api/v2/derp-map` websocket stream."
fix: "Add a stream-level test, or the claim is untested at the documented path."
verified: trueAutomated review via Coder Agents. Reply to a finding's thread with the reason if the finding is wrong. |
matifali
removed their request for review
November 11, 2026 13:21
spikecurtis
approved these changes
Nov 12, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a how-to guide for self-hosting a STUN server with coturn and pointing
CODER_DERP_SERVER_STUN_ADDRESSESat it.The guide is linked from the STUN and NAT page, the networking overview, and the air-gapped comparison table.
Refs #16537, DOCS-310
Verification
coder netcheckagainst a v2.39.0 deployment configured with only self-hosted STUN servers: the coturn 4.6 package under systemd with the documented config, and thecoturn/coturn:4.18.0container with a published UDP port. Hostname and IP entries inCODER_DERP_SERVER_STUN_ADDRESSESboth worked.p2pconnections fromcoder ping, and the STUN servers logged requests from both the client and the agent. With the STUN servers stopped, connections fell back to DERP andcoder pingprinted the "could not connect to STUN over UDP" hints. Running workspaces picked up the new STUN list without a restart.derphealthtest, not committed): with a nil built-in region,tailnet.NewDERPMapdropsCODER_DERP_SERVER_STUN_ADDRESSES, and hand-written STUN-only regions loaded from a relay map file reportcan_stun: true. The documentedjqfilter lists them for both built-in and custom maps.tailnet.STUNRegions), which backs the "two or more servers" advice. With the built-in relay off, a relay map that has only STUN-only nodes fails startup (tailnet.NewDERPMap, pinned byTestNewDERPMap/RequireDERPNodes), which backs the "keep at least one relay node" note.markdownlint, Vale,
lint/emdash,lint/docs-manifest, andlint/docs-htmlpass on the changed files, and a doc-check self-check left no blocking findings.Decision log
stund. It has no releases, packages, or container images, so the guide had readers build an unpinned binary from Tailscale'smainbranch with no distribution security updates. It also answers only binding requests that carry aFINGERPRINTattribute, so generic STUN test tools can't check it. Its only advantage over coturn is a smaller, memory-safe, STUN-only codebase, and coturn'sstun-onlymode covers the practical need.CODER_DERP_SERVER_STUN_ADDRESSES.cli/server.gosets the built-in region tonilwhenCODER_DERP_SERVER_ENABLE=false, andtailnet.NewDERPMapadds STUN regions only when that region exists, numbering them from its region ID. Deployments with a custom relay map add STUN-only regions to that map instead, so the prerequisite became a "Use a custom relay map" section under Configure Coder. The page doesn't drop the relay entirely, because the built-in relay is still required forCODER_DERP_SERVER_STUN_ADDRESSES, and a custom relay map still needs at least one relay node.jqfilter. The old filter matched generatedcoder_stun_*region codes, so it returned an empty list for STUN regions written into a custom relay map. The filter now selects nodes withSTUNOnlyset.Supersedes #31802, reopened under a human author for attribution.
Generated with Coder Agents on behalf of @nickvigilante.