Skip to content

Commit 86e7dae

Browse files
committed
simplified after testing
1 parent 8c343f0 commit 86e7dae

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

examples/web-server/nginx/README.md

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22

33
## Requirements
44

5-
1. You'll need a subdomain and the a wildcard subdomain configured that resolves to server.
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.
7+
> 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.
68
7-
2. Install **nginx** (assuming you're on Debian/Ubuntu):
9+
2. Install NGINX (assuming you're on Debian/Ubuntu):
810

911
```console
1012
sudo apt install nginx
1113
```
1214

13-
3. Stop NGINX:
15+
3. Stop NGINX service:
1416

1517
```console
16-
sudo service stop nginx
18+
sudo systemctl stop nginx
1719
```
1820

1921
## Adding Coder deployment subdomain
@@ -26,7 +28,7 @@
2628
sudo touch /etc/nginx/sites-available/YOUR_SUBDOMAIN
2729
```
2830

29-
2. Activate this file :
31+
2. Activate this file:
3032

3133
```console
3234
sudo ln -s /etc/nginx/sites-available/YOUR_SUBDOMAIN /etc/nginx/sites-enabled/YOUR_SUBDOMAIN
@@ -41,9 +43,17 @@
4143
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:
4244
- Zone - DNS - Edit
4345

44-
2. Create a file in `.secrets/certbot/cloudflare.ini` with the following content :
46+
2. Create a file in `.secrets/certbot/cloudflare.ini` with the following content:
4547

46-
- `dns_cloudflare_api_token = YOUR_API_TOKEN`
48+
```ini
49+
dns_cloudflare_api_token = YOUR_API_TOKEN
50+
```
51+
52+
3. Set the correct permissions:
53+
54+
```console
55+
sudo chmod 600 ~/.secrets/certbot/cloudflare.ini
56+
```
4757

4858
## Create the certificate
4959

@@ -55,13 +65,13 @@
5565

5666
## Configure nginx
5767

58-
1. Edit the file with :
68+
1. Edit the file with:
5969

6070
```console
6171
sudo nano /etc/nginx/sites-available/YOUR_SUBDOMAIN
6272
```
6373

64-
2. Add the following content :
74+
2. Add the following content:
6575

6676
```nginx
6777
server {
@@ -81,14 +91,11 @@
8191
listen 443 ssl;
8292
ssl_certificate /etc/letsencrypt/live/YOUR_SUBDOMAIN/fullchain.pem;
8393
ssl_certificate_key /etc/letsencrypt/live/YOUR_SUBDOMAIN/privkey.pem;
84-
include /etc/letsencrypt/options-ssl-nginx.conf;
85-
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
8694

8795
location / {
8896
proxy_pass http://127.0.0.1:3000; # Change this to your coder deployment port default is 3000
8997
proxy_http_version 1.1;
9098
proxy_set_header Upgrade $http_upgrade;
91-
proxy_set_header Connection $connection_upgrade;
9299
proxy_set_header Host $host;
93100
proxy_set_header X-Real-IP $remote_addr;
94101
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -98,25 +105,25 @@
98105
}
99106
```
100107

101-
> Don't forget to change :
108+
> Don't forget to change:
102109
>
103110
> - `YOUR_SUBDOMAIN` by your (sub)domain e.g. `coder.example.com`
104111

105112
## Refresh certificates automatically
106113

107-
1. Create a new file in `/etc/cron.weekly` :
114+
1. Create a new file in `/etc/cron.weekly`:
108115

109116
```console
110117
sudo touch /etc/cron.weekly/certbot
111118
```
112119

113-
2. Make it executable :
120+
2. Make it executable:
114121

115122
```console
116123
sudo chmod +x /etc/cron.weekly/certbot
117124
```
118125

119-
3. And add this code :
126+
3. And add this code:
120127

121128
```sh
122129
#!/bin/sh
@@ -125,6 +132,6 @@
125132

126133
## Restart NGINX
127134

128-
- `sudo service nginx restart`
135+
- `sudo systemctl restart nginx`
129136

130137
And that's it, you should now be able to access Coder at `https://YOUR_SUBDOMAIN`!

0 commit comments

Comments
 (0)