Skip to content

Commit d65649f

Browse files
bpmctKatie Horne
and
Katie Horne
authored
local preview: add instructions for dev urls (type fixed) (coder#496)
* local preview: add instructions for dev urls * add nip.io instructions * fix broken links * reword dev urls limitation * Edit text * Fix typos * Lint * fix "conf" type Co-authored-by: Katie Horne <katie@coder.com>
1 parent fc323cd commit d65649f

File tree

1 file changed

+107
-12
lines changed

1 file changed

+107
-12
lines changed

setup/kubernetes/local-preview.md

Lines changed: 107 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,7 @@ apply):
5454

5555
1. Docker Desktop for Mac **must** use version [2.5.0.1][docker-mac-url]. This
5656
specific version is required because of a recent downgrade to Linux Kernel
57-
4.9 due to a [bug](docker-bug-url).
58-
59-
### Dev URLs
60-
61-
Currently, the local preview doesn't support [dev URLs][devurl-url]. Instead,
62-
you can use tools like [ngrok][ngrok-url] to preview webpages from inside an
63-
workspace.
64-
65-
We are working on bringing Dev URL support to local previews in later releases.
57+
4.9 due to a [bug][docker-bug-url].
6658

6759
### SSH
6860

@@ -80,19 +72,19 @@ The local preview option does not work in an air-gapped deployment.
8072
To install Coder, run:
8173

8274
```console
83-
curl -fsSL https://coder.com/try.sh | PORT="8080" sh -s --
75+
curl -fsSL https://coder.com/try.sh | PORT="80" sh -s --
8476
```
8577

8678
> Note: you can edit the value of `PORT` to control where the Coder dashboard
87-
> will be available.
79+
> will be available. However, dev URLs will only work when `PORT` is set to `80`.
8880
8981
When the installation process completes, you'll see the URL and login
9082
credentials you need to access Coder:
9183

9284
```txt
9385
You can now access Coder at
9486
95-
http://localhost:8080
87+
http://localhost:80
9688
9789
You can tear down the deployment with
9890
@@ -106,6 +98,90 @@ Password: yfu...yu2
10698
Visit the URL, and log in using the provided credentials. The platform is
10799
automatically configured for you, so there's no first-time setup to do.
108100

101+
### Dev URLs
102+
103+
Coder allows you to access services you're developing in your workspace via [dev
104+
URLs](../../workspaces/devurls.md). You can enable dev URLs after you've
105+
installed Coder.
106+
107+
> If you do not want to enable dev URLs, you can use SSH port forwarding or
108+
> tools like [ngrok][ngrok-url] to preview webpages from inside you workspace.
109+
110+
1. To use dev URLs, you must have a wildcard subdomain. One option to meet this
111+
requirement is to use a service such as [nip.io][nip-url] to route domains to
112+
a local IP address.
113+
114+
1. [Update Coder](../updating.md#update-coder) with the following Helm values
115+
added for either your local (`127.0.0.1`) or private (e.g., `192.168.1.x`)
116+
address:
117+
118+
```yaml
119+
ingress:
120+
host: "127.0.0.1.nip.io"
121+
devurls:
122+
host: "*.127.0.0.1.nip.io"
123+
```
124+
125+
Alternatively, you can use [dnsmasq][dnsmasq-url] to create local domains (e.g.,
126+
`http://dashboard.coder` and `http://*.coder`). This may be useful if you do not
127+
want to rely on an external service/network or if your network has DNS rebinding
128+
protection. Here's how to do this:
129+
130+
1. Install dnsmasq
131+
132+
```console
133+
# Mac OS
134+
brew install dnsmasq
135+
136+
# Linux (Ubuntu)
137+
sudo apt-get install dnsmasq
138+
```
139+
140+
1. Create a dnsmasq configuration for the `.coder` domain
141+
142+
```console
143+
# Mac OS
144+
sudo touch $(brew --prefix)/etc/dnsmasq.d/coder.conf
145+
sudo vim $(brew --prefix)/etc/dnsmasq.d/coder.conf
146+
147+
# Linux (Ubuntu)
148+
sudo touch /etc/dnsmasq.d/coder.conf
149+
sudo vim /etc/dnsmasq.d/coder.conf
150+
```
151+
152+
```text
153+
# coder.conf
154+
address=/coder/127.0.0.1
155+
```
156+
157+
1. Add dnsmasq as DNS resolver on your machine
158+
159+
```console
160+
# Mac OS: this will only route
161+
# .coder domains to dnsmasq
162+
sudo mkdir -p /etc/resolver
163+
sudo touch /etc/resolver/
164+
sudo vim /etc/resolver/coder
165+
166+
# Linux (Ubuntu)
167+
# add to top of the file
168+
sudo vim /etc/resolv.conf
169+
```
170+
171+
```text
172+
nameserver 127.0.0.1
173+
```
174+
175+
1. [Update Coder](../updating#update-coder) with these Helm values added to use
176+
your new domains:
177+
178+
```yaml
179+
ingress:
180+
host: "dashboard.coder"
181+
devurls:
182+
host: "*.coder"
183+
```
184+
109185
## Option 2: Docker Desktop
110186

111187
[Docker Desktop](docker-desktop-url) includes a standalone Kubernetes server and
@@ -155,7 +231,25 @@ curl -fsSL https://coder.com/try.sh | sh -s -- down
155231
Because Coder runs inside Docker, you should have nothing left on your machine
156232
after tear down.
157233

234+
If you added a custom DNS to use [dev URLs](#dev-urls), you can
235+
revert these changes by uninstalling dnsmasq and removing the resolver config:
236+
237+
```console
238+
# MacOS
239+
brew remove dnsmasq
240+
sudo rm -r /etc/resolver/coder
241+
242+
# Linux (Ubuntu)
243+
sudo apt-get remove dnsmasq
244+
sudo vim /etc/resolv.conf
245+
# remove "nameserver 127.0.0.1"
246+
# and ensure you have another
247+
# nameserver specified
248+
# e.g "nameserver 127.0.0.53"
249+
```
250+
158251
[docker-url]: https://www.docker.com/
252+
[dnsmasq-url]: https://linux.die.net/man/8/dnsmasq
159253
[docker-desktop-url]: https://www.docker.com/products/docker-desktop
160254
[docker-k8s-docs]: https://docs.docker.com/desktop/kubernetes/
161255
[kind-url]: https://kind.sigs.k8s.io/
@@ -167,3 +261,4 @@ after tear down.
167261
[docker-bug-url]: https://github.com/docker/for-mac/issues/5044
168262
[ngrok-url]: https://ngrok.com
169263
[devurl-url]: https://coder.com/docs/workspaces/devurls
264+
[nip-url]: https://nip.io

0 commit comments

Comments
 (0)