Skip to content

Commit 021bab1

Browse files
committed
Add an SSL Nginx CertBox tutorial
1 parent cc18465 commit 021bab1

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ SpO₂ is oxygen saturation and is used in medical person monitoring.
44
This project uses [sled](https://github.com/spacejam/sled) to permanently save the health checked URLs.
55
It provides a websocket API that returns the changing status of the health checked URLs.
66

7+
SpO₂ doesn't support SSL out of the box, if you need [you can setup an Nginx server as we do][1].
8+
9+
[1]: /enable-ssl.md
10+
711
## Usage
812

913
You must have installed Rust on your computer.

enable-ssl.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# How to enable SSL for SpO₂
2+
3+
SpO₂ Doesn't support SSL by itself, it is why we used an ngninx on top of it.
4+
Configuring an Nginx to SSL encrypt the HTTP server was easy but the hard part was to encrypt WebSockets.
5+
6+
To make it work you must install CertBot first, it will generate certificates and auto renew them.
7+
Once you have installed CertBot it will automatically manage your certificates and make your domain access secure.
8+
9+
https://certbot.eff.org/lets-encrypt/debianbuster-nginx
10+
11+
Here is an example of our own Nginx configuration after CertBot have been installed:
12+
13+
```Nginx
14+
server {
15+
listen 80;
16+
return 301 https://$host$request_uri;
17+
}
18+
19+
server {
20+
listen 443;
21+
server_name spo2.yourdomainname.com;
22+
ssl_certificate /etc/letsencrypt/live/spo2.yourdomainname.com/fullchain.pem; # managed by Certbot
23+
ssl_certificate_key /etc/letsencrypt/live/spo2.yourdomainname.com/privkey.pem; # managed by Certbot
24+
25+
ssl on;
26+
ssl_session_cache builtin:1000 shared:SSL:10m;
27+
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
28+
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
29+
ssl_prefer_server_ciphers on;
30+
31+
access_log /var/log/nginx/spo2.access.log;
32+
33+
location / {
34+
auth_basic "Please enter the secret password";
35+
auth_basic_user_file /etc/apache2/.htpasswd;
36+
37+
proxy_set_header Host $host;
38+
proxy_set_header X-Real-IP $remote_addr;
39+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
40+
proxy_set_header X-Forwarded-Proto $scheme;
41+
42+
proxy_pass http://localhost:8000;
43+
proxy_read_timeout 90;
44+
45+
proxy_redirect http://localhost:8000 https://spo2.yourdomainname.com;
46+
}
47+
48+
}
49+
50+
upstream appserver {
51+
server localhost:8001;
52+
}
53+
54+
server {
55+
listen 8888;
56+
# server_name spo2.yourdomainname.com;
57+
58+
ssl on;
59+
ssl_certificate /etc/letsencrypt/live/spo2.yourdomainname.com/fullchain.pem; # managed by Certbot
60+
ssl_certificate_key /etc/letsencrypt/live/spo2.yourdomainname.com/privkey.pem; # managed by Certbot
61+
62+
access_log /var/log/nginx/spo2.access.log;
63+
64+
location / {
65+
proxy_pass http://appserver;
66+
proxy_read_timeout 90;
67+
68+
proxy_http_version 1.1;
69+
proxy_set_header Upgrade $http_upgrade;
70+
proxy_set_header Connection "upgrade";
71+
}
72+
}
73+
```

0 commit comments

Comments
 (0)