Skip to content

Commit d71d800

Browse files
committed
add underlying stack doc
1 parent 895965a commit d71d800

File tree

8 files changed

+258
-166
lines changed

8 files changed

+258
-166
lines changed

docs/admin/networking/high-availability.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ connect to the same Postgres endpoint.
3232
HA brings one configuration variable to set in each Coderd node:
3333
`CODER_DERP_SERVER_RELAY_URL`. The HA nodes use these URLs to communicate with
3434
each other. Inter-node communication is only required while using the embedded
35-
relay (default). If you're using [custom relays](./index.md#custom-relays),
35+
relay (default). If you're using [custom relays](./more-networking/index.md#custom-relays),
3636
Coder ignores `CODER_DERP_SERVER_RELAY_URL` since Postgres is the sole
3737
rendezvous for the Coder nodes.
3838

docs/admin/networking/index.md

Lines changed: 6 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ and connection types.
88

99
![Basic user to Coder diagram](../../images/admin/networking/network-stack/network-user-workspace.png)
1010

11+
For more information about the underlying networking stack, Coder agent, or geo-distributed networking, consult [Connections and geo-distribution](./more-networking/index.md). Visit the [troubleshooting doc](./troubleshooting.md) for ways to resolve common issues.
12+
1113
## Coder server, workspaces, users
1214

1315
Coder's network topology has three general types of nodes or ways of interacting
@@ -67,164 +69,14 @@ and the Coder server.
6769

6870
## Web Apps
6971

70-
The Coder servers relays dashboard-initiated connections between the user and
71-
the workspace. Web terminal <-> workspace connections are an exception and may
72-
be direct.
72+
The Coder server relays dashboard-initiated connections between the user and
73+
the workspace.
74+
Connections between the web terminal and workspace are an exception and may be
75+
direct.
7376

7477
In general, [port forwarded](./port-forwarding.md) web apps are faster than
7578
dashboard-accessed web apps.
7679

77-
## 🌎 Geo-distribution
78-
79-
By default, Coder will attempt to create direct peer-to-peer connections between
80-
the client (developer laptop) and workspace.
81-
If this doesn’t work, the end result will be transparent to the end user because
82-
Coder will fall back to connections relayed to the control plane.
83-
84-
### Direct connections
85-
86-
Direct connections reduce latency and improve upload and download speeds for developers.
87-
However, there are many scenarios where direct connections cannot be established,
88-
such as when the Coder [administrators disable direct connections](../../reference/cli/server.md#--block-direct-connections).
89-
90-
Consult the [direct connections section](./troubleshooting.md#common-problems-with-direct-connections)
91-
of the troubleshooting guide for more information.
92-
The troubleshooting guide also explains how to identify if a connection is direct
93-
or not via the `coder ping` command.
94-
95-
Ideally, to speed up direct connections, move the user and workspace closer together.
96-
97-
Establishing a direct connection can be an involved process because both the
98-
client and workspace agent will likely be behind at least one level of NAT,
99-
meaning that we need to use STUN to learn the IP address and port under which
100-
the client and agent can both contact each other. See [STUN and NAT](./stun.md)
101-
for more information on how this process works.
102-
103-
If a direct connection is not available (e.g. client or server is behind NAT),
104-
Coder will use a relayed connection. By default,
105-
[Coder uses Google's public STUN server](../../reference/cli/server.md#--derp-server-stun-addresses),
106-
but this can be disabled or changed for
107-
[offline deployments](../../install/offline.md).
108-
109-
In order for clients to be able to establish direct connections:
110-
111-
> **Note:** Direct connections via the web browser are not supported. To improve
112-
> latency for browser-based applications running inside Coder workspaces in
113-
> regions far from the Coder control plane, consider deploying one or more
114-
> [workspace proxies](./workspace-proxies.md).
115-
116-
- The client is connecting using the CLI (e.g. `coder ssh` or
117-
`coder port-forward`). Note that the
118-
[VSCode extension](https://marketplace.visualstudio.com/items?itemName=coder.coder-remote)
119-
and [JetBrains Plugin](https://plugins.jetbrains.com/plugin/19620-coder/), and
120-
[`ssh coder.<workspace>`](../../reference/cli/config-ssh.md) all utilize the
121-
CLI to establish a workspace connection.
122-
- Either the client or workspace agent are able to discover a reachable
123-
`ip:port` of their counterpart. If the agent and client are able to
124-
communicate with each other using their locally assigned IP addresses, then a
125-
direct connection can be established immediately. Otherwise, the client and
126-
agent will contact
127-
[the configured STUN servers](../../reference/cli/server.md#--derp-server-stun-addresses)
128-
to try and determine which `ip:port` can be used to communicate with their
129-
counterpart. See [STUN and NAT](./stun.md) for more details on how this
130-
process works.
131-
- All outbound UDP traffic must be allowed for both the client and the agent on
132-
**all ports** to each others' respective networks.
133-
- To establish a direct connection, both agent and client use STUN. This
134-
involves sending UDP packets outbound on `udp/3478` to the configured
135-
[STUN server](../../reference/cli/server.md#--derp-server-stun-addresses).
136-
If either the agent or the client are unable to send and receive UDP packets
137-
to a STUN server, then direct connections will not be possible.
138-
- Both agents and clients will then establish a
139-
[WireGuard](https://www.wireguard.com/)️ tunnel and send UDP traffic on
140-
ephemeral (high) ports. If a firewall between the client and the agent
141-
blocks this UDP traffic, direct connections will not be possible.
142-
143-
### Relayed connections
144-
145-
By default, your Coder server also runs a built-in DERP relay which can be used
146-
for both public and [offline deployments](../../install/offline.md).
147-
148-
However, our Wireguard integration through Tailscale has graciously allowed us
149-
to use
150-
[their global DERP relays](https://tailscale.com/kb/1118/custom-derp-servers/#what-are-derp-servers).
151-
You can launch `coder server` with Tailscale's DERPs like so:
152-
153-
```bash
154-
coder server --derp-config-url https://controlplane.tailscale.com/derpmap/default
155-
```
156-
157-
#### Custom Relays
158-
159-
If you want lower latency than what Tailscale offers or want additional DERP
160-
relays for offline deployments, you may run custom DERP servers. Refer to
161-
[Tailscale's documentation](https://tailscale.com/kb/1118/custom-derp-servers/#why-run-your-own-derp-server)
162-
to learn how to set them up.
163-
164-
After you have custom DERP servers, you can launch Coder with them like so:
165-
166-
```json
167-
# derpmap.json
168-
{
169-
"Regions": {
170-
"1": {
171-
"RegionID": 1,
172-
"RegionCode": "myderp",
173-
"RegionName": "My DERP",
174-
"Nodes": [
175-
{
176-
"Name": "1",
177-
"RegionID": 1,
178-
"HostName": "your-hostname.com"
179-
}
180-
]
181-
}
182-
}
183-
}
184-
```
185-
186-
```bash
187-
coder server --derp-config-path derpmap.json
188-
```
189-
190-
### Dashboard connections
191-
192-
The dashboard (and web apps opened through the dashboard) are served from the
193-
Coder server, so they can only be geo-distributed with High Availability mode in
194-
our Premium Edition. [Reach out to Sales](https://coder.com/contact) to learn
195-
more.
196-
197-
## Browser-only connections
198-
199-
<blockquote class="info">
200-
201-
Browser-only connections is an Enterprise and Premium feature.
202-
[Learn more](https://coder.com/pricing#compare-plans).
203-
204-
</blockquote>
205-
206-
Some Coder deployments require that all access is through the browser to comply
207-
with security policies. In these cases, pass the `--browser-only` flag to
208-
`coder server` or set `CODER_BROWSER_ONLY=true`.
209-
210-
With browser-only connections, developers can only connect to their workspaces
211-
via the web terminal and
212-
[web IDEs](../../user-guides/workspace-access/web-ides.md).
213-
214-
### Workspace Proxies
215-
216-
<blockquote class="info">
217-
218-
Workspace proxies are an Enterprise and Premium feature.
219-
[Learn more](https://coder.com/pricing#compare-plans).
220-
221-
</blockquote>
222-
223-
Workspace proxies are a Coder Enterprise feature that allows you to provide
224-
low-latency browser experiences for geo-distributed teams.
225-
226-
To learn more, see [Workspace Proxies](./workspace-proxies.md).
227-
22880
## Up next
22981

23082
- Learn about [Port Forwarding](./port-forwarding.md)
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# Connections and geo-distribution
2+
3+
## SSH and browser connections
4+
5+
Coder workspaces have SSH support which allows the use of desktop editors such
6+
as VS Code remote connections and JetBrains Gateway.
7+
8+
SSH connections require that you open port 443 on the server.
9+
10+
Coder does not require workspaces to have port 22 open, an OpenSSH server running,
11+
nor SSH keys.
12+
Instead, Coder mimics SSH over an HTTPS tunnel and uses the user’s session token
13+
through the CLI to authenticate.
14+
This is more secure and portable than SSH relays, bastion hosts, and other methods
15+
because it ensures that only the proper user session can establish SSH connections.
16+
17+
Administrators can disable this by enabling [browser-only mode](#browser-only-connections),
18+
allowing only connections to workspaces through the browser like code-server,
19+
web terminal, web RDP, and others.
20+
21+
### Browser-only connections
22+
23+
<blockquote class="info">
24+
25+
Browser-only connections is an Enterprise and Premium feature.
26+
[Learn more](https://coder.com/pricing#compare-plans).
27+
28+
</blockquote>
29+
30+
Some Coder deployments require that all access is through the browser to comply
31+
with security policies. In these cases, pass the `--browser-only` flag to
32+
`coder server` or set `CODER_BROWSER_ONLY=true`.
33+
34+
With browser-only connections, developers can only connect to their workspaces
35+
via the web terminal and
36+
[web IDEs](../../user-guides/workspace-access/web-ides.md).
37+
38+
## 🌎 Geo-distribution
39+
40+
Workspace proxies and provisioners can be deployed for low-latency access to
41+
workspaces for distributed teams.
42+
43+
By default, Coder will attempt to create direct peer-to-peer connections between
44+
the client (developer laptop) and workspace.
45+
If this doesn’t work, the end result will be transparent to the end user because
46+
Coder will fall back to connections relayed to the control plane.
47+
48+
Since Coder supports deploying resources in multiple regions, developers will want a fast connection to those workspaces. Workspace proxies are designed to relay traffic to workspaces without having to route traffic to the central Coder server. Both web traffic and SSH traffic is relayed through workspace proxies.
49+
50+
### Workspace Proxies
51+
52+
[Workspace Proxies](./workspace-proxies.md) are a
53+
[Premium](https://coder.com/pricing#compare-plans) feature that allows you to
54+
provide low-latency browser experiences for geo-distributed teams.
55+
56+
### Direct connections
57+
58+
Direct connections reduce latency and improve upload and download speeds for developers.
59+
However, there are many scenarios where direct connections cannot be established,
60+
such as when the Coder [administrators disable direct connections](../../reference/cli/server.md#--block-direct-connections).
61+
62+
Consult the [direct connections section](./troubleshooting.md#common-problems-with-direct-connections)
63+
of the troubleshooting guide for more information.
64+
The troubleshooting guide also explains how to identify if a connection is direct
65+
or not via the `coder ping` command.
66+
67+
Ideally, to speed up direct connections, move the user and workspace closer together.
68+
69+
Establishing a direct connection can be an involved process because both the
70+
client and workspace agent will likely be behind at least one level of NAT,
71+
meaning that we need to use STUN to learn the IP address and port under which
72+
the client and agent can both contact each other. See [STUN and NAT](./stun.md)
73+
for more information on how this process works.
74+
75+
If a direct connection is not available (e.g. client or server is behind NAT),
76+
Coder will use a relayed connection. By default,
77+
[Coder uses Google's public STUN server](../../reference/cli/server.md#--derp-server-stun-addresses),
78+
but this can be disabled or changed for
79+
[offline deployments](../../install/offline.md).
80+
81+
In order for clients to be able to establish direct connections:
82+
83+
> **Note:** Direct connections via the web browser are not supported. To improve
84+
> latency for browser-based applications running inside Coder workspaces in
85+
> regions far from the Coder control plane, consider deploying one or more
86+
> [workspace proxies](./workspace-proxies.md).
87+
88+
- The client is connecting using the CLI (e.g. `coder ssh` or
89+
`coder port-forward`). Note that the
90+
[VSCode extension](https://marketplace.visualstudio.com/items?itemName=coder.coder-remote)
91+
and [JetBrains Plugin](https://plugins.jetbrains.com/plugin/19620-coder/), and
92+
[`ssh coder.<workspace>`](../../reference/cli/config-ssh.md) all utilize the
93+
CLI to establish a workspace connection.
94+
- Either the client or workspace agent are able to discover a reachable
95+
`ip:port` of their counterpart. If the agent and client are able to
96+
communicate with each other using their locally assigned IP addresses, then a
97+
direct connection can be established immediately. Otherwise, the client and
98+
agent will contact
99+
[the configured STUN servers](../../reference/cli/server.md#--derp-server-stun-addresses)
100+
to try and determine which `ip:port` can be used to communicate with their
101+
counterpart. See [STUN and NAT](./stun.md) for more details on how this
102+
process works.
103+
- All outbound UDP traffic must be allowed for both the client and the agent on
104+
**all ports** to each others' respective networks.
105+
- To establish a direct connection, both agent and client use STUN. This
106+
involves sending UDP packets outbound on `udp/3478` to the configured
107+
[STUN server](../../reference/cli/server.md#--derp-server-stun-addresses).
108+
If either the agent or the client are unable to send and receive UDP packets
109+
to a STUN server, then direct connections will not be possible.
110+
- Both agents and clients will then establish a
111+
[WireGuard](https://www.wireguard.com/)️ tunnel and send UDP traffic on
112+
ephemeral (high) ports. If a firewall between the client and the agent
113+
blocks this UDP traffic, direct connections will not be possible.
114+
115+
### Relayed connections
116+
117+
By default, your Coder server also runs a built-in DERP relay which can be used
118+
for both public and [offline deployments](../../install/offline.md).
119+
120+
However, our Wireguard integration through Tailscale has graciously allowed us
121+
to use
122+
[their global DERP relays](https://tailscale.com/kb/1118/custom-derp-servers/#what-are-derp-servers).
123+
You can launch `coder server` with Tailscale's DERPs like so:
124+
125+
```bash
126+
coder server --derp-config-url https://controlplane.tailscale.com/derpmap/default
127+
```
128+
129+
#### Custom Relays
130+
131+
If you want lower latency than what Tailscale offers or want additional DERP
132+
relays for offline deployments, you may run custom DERP servers. Refer to
133+
[Tailscale's documentation](https://tailscale.com/kb/1118/custom-derp-servers/#why-run-your-own-derp-server)
134+
to learn how to set them up.
135+
136+
After you have custom DERP servers, you can launch Coder with them like so:
137+
138+
```json
139+
# derpmap.json
140+
{
141+
"Regions": {
142+
"1": {
143+
"RegionID": 1,
144+
"RegionCode": "myderp",
145+
"RegionName": "My DERP",
146+
"Nodes": [
147+
{
148+
"Name": "1",
149+
"RegionID": 1,
150+
"HostName": "your-hostname.com"
151+
}
152+
]
153+
}
154+
}
155+
}
156+
```
157+
158+
```bash
159+
coder server --derp-config-path derpmap.json
160+
```
161+
162+
### Dashboard connections
163+
164+
The dashboard (and web apps opened through the dashboard) are served from the
165+
Coder server, so they can only be geo-distributed with High Availability mode in
166+
our Premium Edition. [Reach out to Sales](https://coder.com/contact) to learn
167+
more.

0 commit comments

Comments
 (0)