Skip to content

Commit bab822e

Browse files
authored
credits & markdown formatting (#165)
* credits & markdown formatting giving credit to the original author & fixing some markdown formatting issues * minor markdaown fix
1 parent 497f8b9 commit bab822e

2 files changed

Lines changed: 42 additions & 34 deletions

File tree

docs/infrastructure/access_System.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ The keycode access system runs in parallel with the fob access system.
66
### Hardware
77

88
It consists of:
9-
* A keypad outside
10-
* A pi Inside
11-
* A relay board inside
9+
- A keypad outside
10+
- A pi Inside
11+
- A relay board inside
1212

1313
### Getting access codes
1414
The Pi gets a (`announce_name`, `fob_id`) CSV list of valid members every few minutes from the membership system and stores this locally.

docs/infrastructure/nginx.md

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# NGINX Setup
22

3+
Original article - https://francoisromain.medium.com/host-multiple-websites-with-https-inside-docker-containers-on-a-single-server-18467484ab95
4+
35
## Hosting multiple websites on a single Virtual Private Server is simple and efficient. Nowadays, HTTPS is a required feature for any website.
46

57
----------
@@ -27,16 +29,17 @@ The manual way to setup a nginx reverse-proxy is to install nginx directly on th
2729
- The need to restart nginx after each config modification, causing a short downtime for every websites.
2830
- The need to expose a port of each container to the host, and therefore keep track of the used ports (two containers can not use the same port).
2931

30-
**To avoid these downsides, the magic** `[**jwilder/nginx-proxy**](https://github.com/jwilder/nginx-proxy)` **automates the creation of nginx configs and reloads the proxy server when a container starts and stops. And it has HTTPS support.**
32+
**To avoid these downsides, the magic** [jwilder/nginx-proxy](https://github.com/jwilder/nginx-proxy) **automates the creation of nginx configs and reloads the proxy server when a container starts and stops. And it has HTTPS support.**
3133

32-
**Even better, the nginx-proxy has a** `[**LetsEncrypt companion**](https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion)`**, which allows the automatic creation and renewal of HTTPS certificates.**
34+
**Even better, the nginx-proxy has a** [LetsEncrypt companion](https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion)**, which allows the automatic creation and renewal of HTTPS certificates.**
3335

3436
**In one word: set-it-and-forget-it.**
3537

3638
# Project structure
3739

3840
Create a `nginx-proxy` directory next to the websites directories. In my setup this is in `/srv/www/` on the host.
3941

42+
```
4043
.
4144
+-- nginx-proxy
4245
| +-- docker-compose.yml
@@ -48,13 +51,15 @@ Create a `nginx-proxy` directory next to the websites directories. In my setup
4851
+-- your-website-one.tld
4952
+-- your-website-two.tld
5053
+-- your-website-three.tld
54+
```
5155

5256
Inside `/nginx-proxy`, create four empty directories: `conf.d`, `vhost.d`, `html` and `certs`. These are used to store the nginx and the Let’s Encrypt configuration files.
5357

5458
# **docker-compose.yml**
5559

5660
Inside `/nginx-proxy/`, create a `docker-compose.yml` file with this content:
5761

62+
```
5863
version: '3'services:
5964
nginx:
6065
image: nginx
@@ -100,29 +105,30 @@ version: '3'services:
100105
default:
101106
external:
102107
name: nginx-proxy
108+
```
103109

104110
This will launch three services:
105111

106112
- `nginx`: the nginx-reverse proxy, uses the default nginx image. The label is needed so that the letsencrypt container knows which nginx proxy container to use.
107-
- `nginx-gen`: uses the `[jwilder/docker-gen](https://github.com/jwilder/docker-gen)` image. Its `command` instruction will render a nginx configuration (based on `nginx.tmpl`) for each website / container added to the network.
113+
- `nginx-gen`: uses the [jwilder/docker-gen](https://github.com/jwilder/docker-gen) image. Its `command` instruction will render a nginx configuration (based on `nginx.tmpl`) for each website / container added to the network.
108114
- `nginx-letsencrypt`: generates and renew the HTTPS certificates.
109115

110116
All these services are bound to the `nginx-proxy` network.
111117

112118
# nginx.tmpl
113119

114-
Inside `/nginx-proxy/`, create a `nginx.tmpl` file and copy the content from [this file](https://raw.githubusercontent.com/jwilder/nginx-proxy/master/nginx.tmpl). This is the used by the `nginx-gen` container to create the nginx configuration file for each website / container added to the network.
120+
Inside `/nginx-proxy/`, create a `nginx.tmpl` file and copy the content from [this file](https://raw.githubusercontent.com/jwilder/nginx-proxy/master/nginx.tmpl). This is the used by the `nginx-gen` container to create the nginx configuration file for each website / container added to the network.
115121

116122
# Boot up
117123

118124
First create the network:
119125

120-
$ docker network create nginx-proxy
126+
`$ docker network create nginx-proxy`
121127

122-
Then create the reverse proxy with the `nginx`, `nginx-gen` and `nginx-letsencrypt` containers from the `docker-compose.yml` file:
128+
Then create the reverse proxy with the `nginx`, `nginx-gen` and `nginx-letsencrypt` containers from the `docker-compose.yml` file:
123129

124-
$ cd /srv/www/nginx-proxy/
125-
$ docker-compose up -d
130+
`$ cd /srv/www/nginx-proxy/`
131+
`$ docker-compose up -d`
126132

127133
Now the reverse-proxy is running.
128134

@@ -132,14 +138,16 @@ To link a website to the running nginx-proxy, we need to update its own `docker
132138

133139
**1. Environment variables**
134140

135-
services:
136-
my-app:
137-
138-
environment:
139-
VIRTUAL_HOST: your-website.tld
140-
VIRTUAL_PORT: 3000
141-
LETSENCRYPT_HOST: your-website.tld
141+
```
142+
services:
143+
my-app:
144+
145+
environment:
146+
VIRTUAL_HOST: your-website.tld
147+
VIRTUAL_PORT: 3000
148+
LETSENCRYPT_HOST: your-website.tld
142149
LETSENCRYPT_EMAIL: your-email@domain.tld
150+
```
143151

144152
- `VIRTUAL_HOST`: your domain name, used in the nginx configuration.
145153
- `VIRTUAL_PORT`: (opt.) the port your website is listening to (default to `80`).
@@ -148,27 +156,31 @@ services:
148156

149157
**2. Ports**
150158

151-
services:
152-
my-app:
153-
154-
expose:
159+
```
160+
services:
161+
my-app:
162+
163+
expose:
155164
- 3000
165+
```
156166

157167
Same as the `VIRTUAL_PORT` above.
158168

159169
**3. Network**
160170

161-
networks:
162-
default:
163-
external:
171+
```
172+
networks:
173+
default:
174+
external:
164175
name: nginx-proxy
176+
```
165177

166178
**Now lets start the website with:**
167179

168-
$ cd /srv/www/your-website.tld
169-
$ docker-compose up -d
180+
`$ cd /srv/www/your-website.tld`
181+
`$ docker-compose up -d`
170182

171-
**The website is automatically detected by the reverse proxy, has a HTTPS certificate and is visible at** `**https://your-website.tld**`**.**
183+
**The website is automatically detected by the reverse proxy, has a HTTPS certificate and is visible at https://your-website.tld .**
172184

173185
**Magic!**
174186

@@ -179,14 +191,10 @@ How can we replicate this production environment, on a local dev computer? I wro
179191
# Useful links
180192

181193
- [A complete guide to switching from HTTP to HTTPS](https://www.smashingmagazine.com/2017/06/guide-switching-http-https/): a very rich article explaining what HTTPS is technically, the different types of certificates and different ways to set it up on a server.
182-
- A [Docker Compose with nginx-proxy and Let’s Encrypt](https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion) example by Ever Tramos automates the steps exposed in this article.
183-
184-
#### 1K
185-
186-
#### 30
194+
- A [Docker Compose with nginx-proxy and Let’s Encrypt](https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion) example by Ever Tramos automates the steps exposed in this article.
187195

188196
- [Docker](https://medium.com/tag/docker)
189197
- [Nginx](https://medium.com/tag/nginx)
190198
- [Vps Hosting](https://medium.com/tag/vps-hosting)
191199
- [Lets Encrypt](https://medium.com/tag/lets-encrypt)
192-
- [Https](https://medium.com/tag/https)
200+
- [Https](https://medium.com/tag/https)

0 commit comments

Comments
 (0)