@@ -11,31 +11,101 @@ certificates, you'll need a domain name that resolves to your Caddy server.
11111 . [ Install Docker] ( https://docs.docker.com/engine/install/ ) and
1212 [ Docker Compose] ( https://docs.docker.com/compose/install/ )
1313
14- 1 . Start with our example configuration
14+ 2 . Create a ` docker-compose.yaml ` file and add the following:
15+
16+ ``` yaml
17+ services :
18+ coder :
19+ image : ghcr.io/coder/coder:${CODER_VERSION:-latest}
20+ environment :
21+ CODER_PG_CONNECTION_URL : " postgresql://${POSTGRES_USER:-username}:${POSTGRES_PASSWORD:-password}@database/${POSTGRES_DB:-coder}?sslmode=disable"
22+ CODER_HTTP_ADDRESS : " 0.0.0.0:7080"
23+ # You'll need to set CODER_ACCESS_URL to an IP or domain
24+ # that workspaces can reach. This cannot be localhost
25+ # or 127.0.0.1 for non-Docker templates!
26+ CODER_ACCESS_URL : " ${CODER_ACCESS_URL}"
27+ # Optional) Enable wildcard apps/dashboard port forwarding
28+ CODER_WILDCARD_ACCESS_URL : " ${CODER_WILDCARD_ACCESS_URL}"
29+ # If the coder user does not have write permissions on
30+ # the docker socket, you can uncomment the following
31+ # lines and set the group ID to one that has write
32+ # permissions on the docker socket.
33+ # group_add:
34+ # - "998" # docker group on host
35+ volumes :
36+ - /var/run/docker.sock:/var/run/docker.sock
37+ depends_on :
38+ database :
39+ condition : service_healthy
40+
41+ database :
42+ image : " postgres:16"
43+ ports :
44+ - " 5432:5432"
45+ environment :
46+ POSTGRES_USER : ${POSTGRES_USER:-username} # The PostgreSQL user (useful to connect to the database)
47+ POSTGRES_PASSWORD : ${POSTGRES_PASSWORD:-password} # The PostgreSQL password (useful to connect to the database)
48+ POSTGRES_DB : ${POSTGRES_DB:-coder} # The PostgreSQL default database (automatically created at first launch)
49+ volumes :
50+ - coder_data:/var/lib/postgresql/data # Use "docker volume rm coder_coder_data" to reset Coder
51+ healthcheck :
52+ test :
53+ [
54+ " CMD-SHELL" ,
55+ " pg_isready -U ${POSTGRES_USER:-username} -d ${POSTGRES_DB:-coder}" ,
56+ ]
57+ interval : 5s
58+ timeout : 5s
59+ retries : 5
60+
61+ caddy :
62+ image : caddy:2.6.2
63+ ports :
64+ - " 80:80"
65+ - " 443:443"
66+ - " 443:443/udp"
67+ volumes :
68+ - $PWD/Caddyfile:/etc/caddy/Caddyfile
69+ - caddy_data:/data
70+ - caddy_config:/config
71+
72+ volumes :
73+ coder_data :
74+ caddy_data :
75+ caddy_config :
76+ ` ` `
1577
16- ``` shell
17- # Create a project folder
18- cd $HOME
19- mkdir coder-with-caddy
20- cd coder-with-caddy
21-
22- # Clone coder/coder and copy the Caddy example
23- git clone https://github.com/coder/coder /tmp/coder
24- mv /tmp/coder/docs/admin/setup/web-server/caddy $( pwd)
78+ 3. Create a ` Caddyfile` and add the following:
79+
80+ ` ` ` caddyfile
81+ {
82+ on_demand_tls {
83+ ask http://example.com
84+ }
85+ }
86+
87+ coder.example.com, *.coder.example.com {
88+ reverse_proxy coder:7080
89+ tls {
90+ on_demand
91+ issuer acme {
92+ 93+ }
94+ }
95+ }
2596 ` ` `
2697
27- 1 . Modify the [ Caddyfile ] ( ./Caddyfile ) and change the following values:
98+ Here;
2899
29- - ` localhost:3000 ` : Change to ` coder:7080 ` (Coder container on Docker
30- network)
100+ - ` coder:7080` is the address of the Coder container on the Docker network.
101+ - ` coder.example.com` is the domain name you're using for Coder.
102+ - ` *.coder.example.com` is the domain name for wildcard apps, commonly used
103+ for [dashboard port forwarding](../admin/networking/port-forwarding.md).
104+ This is optional and can be removed.
31105 -
`[email protected] ` :
Email to request certificates from LetsEncrypt/ZeroSSL 32106 (does not have to be Coder admin email)
33- - ` coder.example.com ` : Domain name you're using for Coder.
34- - ` *.coder.example.com ` : Domain name for wildcard apps, commonly used for
35- [ dashboard port forwarding] ( ../../../networking/port-forwarding.md ) . This
36- is optional and can be removed.
37107
38- 1 . Start Coder. Set ` CODER_ACCESS_URL ` and ` CODER_WILDCARD_ACCESS_URL ` to the
108+ 4 . Start Coder. Set `CODER_ACCESS_URL` and `CODER_WILDCARD_ACCESS_URL` to the
39109 domain you're using in your Caddyfile.
40110
41111 ` ` ` shell
@@ -46,11 +116,23 @@ certificates, you'll need a domain name that resolves to your Caddy server.
46116
47117# ## Standalone
48118
49- 1 . If you haven't already, [ install Coder] ( ../../../../ install/index.md )
119+ 1. If you haven't already, [install Coder](../install/index.md)
50120
511212. Install [Caddy Server](https://caddyserver.com/docs/install)
52122
53- 3 . Copy our sample [ Caddyfile] ( ./Caddyfile ) and change the following values:
123+ 3. Copy our sample `Caddyfile` and change the following values :
124+
125+ ` ` ` caddyfile
126+ {
127+ on_demand_tls {
128+ ask http://example.com
129+ }
130+ }
131+
132+ coder.example.com, *.coder.example.com {
133+ reverse_proxy coder:7080
134+ }
135+ ` ` `
54136
55137 > If you're installed Caddy as a system package, update the default Caddyfile
56138 > with `vim /etc/caddy/Caddyfile`
@@ -59,14 +141,14 @@ certificates, you'll need a domain name that resolves to your Caddy server.
59141 (does not have to be Coder admin email)
60142 - `coder.example.com` : Domain name you're using for Coder.
61143 - `*.coder.example.com` : Domain name for wildcard apps, commonly used for
62- [ dashboard port forwarding] ( ../../.. /networking/port-forwarding.md ) . This
144+ [dashboard port forwarding](../admin /networking/port-forwarding.md). This
63145 is optional and can be removed.
64146 - `localhost:3000` : Address Coder is running on. Modify this if you changed
65147 ` CODER_HTTP_ADDRESS` in the Coder configuration.
66148 - _DO NOT CHANGE the `ask http://example.com` line! Doing so will result in
67149 your certs potentially not being generated._
68150
69- 4 . [ Configure Coder] ( ../.. /index.md ) and change the following values:
151+ 4. [Configure Coder](../admin/setup /index.md) and change the following values :
70152
71153 - `CODER_ACCESS_URL` : root domain (e.g. `https://coder.example.com`)
72154 - `CODER_WILDCARD_ACCESS_URL` : wildcard domain (e.g. `*.example.com`).
@@ -116,7 +198,7 @@ By default, this configuration uses Caddy's
116198[on-demand TLS](https://caddyserver.com/docs/caddyfile/options#on-demand-tls) to
117199generate a certificate for each subdomain (e.g. `app1.coder.example.com`,
118200` app2.coder.example.com` ). When users visit new subdomains, such as accessing
119- [ ports on a workspace] ( ../../.. /networking/port-forwarding.md ) , the request will
201+ [ports on a workspace](../admin /networking/port-forwarding.md), the request will
120202take an additional 5-30 seconds since a new certificate is being generated.
121203
122204For production deployments, we recommend configuring Caddy to generate a
0 commit comments