Skip to content

Commit 7d28e51

Browse files
committed
fmt: prettier formatting
1 parent 86e7dae commit 7d28e51

File tree

1 file changed

+73
-70
lines changed

1 file changed

+73
-70
lines changed

examples/web-server/nginx/README.md

Lines changed: 73 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,39 @@
22

33
## Requirements
44

5-
1. Start a Coder deployment with a wildcard subdomain. See [this guide](https://coder.com/docs/coder/v1.20/setup/installation#step-1-create-a-subdomain) for more information.
6-
1. You'll need a subdomain and the a wildcard subdomain configured that resolves to server's public ip.
5+
1. Start a Coder deployment with a wildcard subdomain. See [this guide](https://coder.com/docs/v2/latest/admin/configure#wildcard-access-url) for more information.
6+
7+
2. You'll need a subdomain and the a wildcard subdomain configured that resolves to server's public ip.
8+
79
> For example, to use `coder.example.com` as your subdomain, configure `coder.example.com` and `*.coder.example.com` to point to your server's public ip. This can be done by adding A records in your DNS provider's dashboard.
810
9-
2. Install NGINX (assuming you're on Debian/Ubuntu):
11+
3. Install NGINX (assuming you're on Debian/Ubuntu):
1012

11-
```console
12-
sudo apt install nginx
13-
```
13+
```console
14+
sudo apt install nginx
15+
```
1416

15-
3. Stop NGINX service:
17+
4. Stop NGINX service:
1618

17-
```console
18-
sudo systemctl stop nginx
19-
```
19+
```console
20+
sudo systemctl stop nginx
21+
```
2022

2123
## Adding Coder deployment subdomain
2224

2325
> This example assumes Coder is running locally on `127.0.0.1:3000` for the subdomain `YOUR_SUBDOMAIN` e.g. `coder.example.com`.
2426
2527
1. Create NGINX configuration for this app:
2628

27-
```console
28-
sudo touch /etc/nginx/sites-available/YOUR_SUBDOMAIN
29-
```
29+
```console
30+
sudo touch /etc/nginx/sites-available/YOUR_SUBDOMAIN
31+
```
3032

3133
2. Activate this file:
3234

33-
```console
34-
sudo ln -s /etc/nginx/sites-available/YOUR_SUBDOMAIN /etc/nginx/sites-enabled/YOUR_SUBDOMAIN
35-
```
35+
```console
36+
sudo ln -s /etc/nginx/sites-available/YOUR_SUBDOMAIN /etc/nginx/sites-enabled/YOUR_SUBDOMAIN
37+
```
3638

3739
## Install and configure LetsEncrypt Certbot
3840

@@ -41,69 +43,70 @@
4143
## Create DNS provider credentials
4244

4345
1. Create an API token for the DNS provider you're using: e.g [CloudFlare](https://dash.cloudflare.com/profile/api-tokens) with the following permissions:
44-
- Zone - DNS - Edit
46+
47+
- Zone - DNS - Edit
4548

4649
2. Create a file in `.secrets/certbot/cloudflare.ini` with the following content:
4750

48-
```ini
49-
dns_cloudflare_api_token = YOUR_API_TOKEN
50-
```
51+
```ini
52+
dns_cloudflare_api_token = YOUR_API_TOKEN
53+
```
5154

5255
3. Set the correct permissions:
5356

54-
```console
55-
sudo chmod 600 ~/.secrets/certbot/cloudflare.ini
56-
```
57+
```console
58+
sudo chmod 600 ~/.secrets/certbot/cloudflare.ini
59+
```
5760

5861
## Create the certificate
5962

6063
1. Create the wildcard certificate:
6164

62-
```console
63-
sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials ~/.secrets/certbot/cloudflare.ini -d coder.example.com -d *.coder.example.com
64-
```
65+
```console
66+
sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials ~/.secrets/certbot/cloudflare.ini -d coder.example.com -d *.coder.example.com
67+
```
6568

6669
## Configure nginx
6770

6871
1. Edit the file with:
6972

70-
```console
71-
sudo nano /etc/nginx/sites-available/YOUR_SUBDOMAIN
72-
```
73+
```console
74+
sudo nano /etc/nginx/sites-available/YOUR_SUBDOMAIN
75+
```
7376

7477
2. Add the following content:
7578

76-
```nginx
77-
server {
78-
server_name YOUR_SUBDOMAIN *.YOUR_SUBDOMAIN;
79-
80-
# HTTP configuration
81-
listen 80;
82-
listen [::]:80;
83-
84-
# HTTP to HTTPS
85-
if ($scheme != "https") {
86-
return 301 https://$host$request_uri;
87-
}
88-
89-
# HTTPS configuration
90-
listen [::]:443 ssl ipv6only=on;
91-
listen 443 ssl;
92-
ssl_certificate /etc/letsencrypt/live/YOUR_SUBDOMAIN/fullchain.pem;
93-
ssl_certificate_key /etc/letsencrypt/live/YOUR_SUBDOMAIN/privkey.pem;
94-
95-
location / {
96-
proxy_pass http://127.0.0.1:3000; # Change this to your coder deployment port default is 3000
97-
proxy_http_version 1.1;
98-
proxy_set_header Upgrade $http_upgrade;
99-
proxy_set_header Host $host;
100-
proxy_set_header X-Real-IP $remote_addr;
101-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
102-
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
103-
add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always;
104-
}
105-
}
106-
```
79+
```nginx
80+
server {
81+
server_name YOUR_SUBDOMAIN *.YOUR_SUBDOMAIN;
82+
83+
# HTTP configuration
84+
listen 80;
85+
listen [::]:80;
86+
87+
# HTTP to HTTPS
88+
if ($scheme != "https") {
89+
return 301 https://$host$request_uri;
90+
}
91+
92+
# HTTPS configuration
93+
listen [::]:443 ssl ipv6only=on;
94+
listen 443 ssl;
95+
ssl_certificate /etc/letsencrypt/live/YOUR_SUBDOMAIN/fullchain.pem;
96+
ssl_certificate_key /etc/letsencrypt/live/YOUR_SUBDOMAIN/privkey.pem;
97+
98+
location / {
99+
proxy_pass http://127.0.0.1:3000; # Change this to your coder deployment port default is 3000
100+
proxy_http_version 1.1;
101+
proxy_set_header Upgrade $http_upgrade;
102+
proxy_set_header Host $host;
103+
proxy_set_header X-Real-IP $remote_addr;
104+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
105+
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
106+
add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always;
107+
}
108+
}
109+
```
107110

108111
> Don't forget to change:
109112
>
@@ -113,22 +116,22 @@
113116

114117
1. Create a new file in `/etc/cron.weekly`:
115118

116-
```console
117-
sudo touch /etc/cron.weekly/certbot
118-
```
119+
```console
120+
sudo touch /etc/cron.weekly/certbot
121+
```
119122

120123
2. Make it executable:
121124

122-
```console
123-
sudo chmod +x /etc/cron.weekly/certbot
124-
```
125+
```console
126+
sudo chmod +x /etc/cron.weekly/certbot
127+
```
125128

126129
3. And add this code:
127130

128-
```sh
129-
#!/bin/sh
130-
sudo certbot renew -q
131-
```
131+
```sh
132+
#!/bin/sh
133+
sudo certbot renew -q
134+
```
132135

133136
## Restart NGINX
134137

0 commit comments

Comments
 (0)