-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5bed46
commit 78b86d7
Showing
3 changed files
with
97 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
## Reference | ||
https://medium.com/@gary.ascuy/docker-free-ssl-tls-certs-lets-encrypt-184e62ab272e | ||
|
||
## Local server setup | ||
|
||
```shell | ||
curl -fsSL https://get.docker.com | sh | ||
``` | ||
```shell | ||
sudo apt install git | ||
``` | ||
|
||
```shell | ||
git clone https://github.com/BenjaminPelletier/aerodata | ||
``` | ||
|
||
```shell | ||
cd aerodata | ||
``` | ||
|
||
```shell | ||
sudo ./run.sh | ||
``` | ||
|
||
## nginx setup | ||
|
||
```shell | ||
sudo docker run --rm -p 80:80 -p 443:443 \ | ||
-v /root/nginx/letsencrypt:/etc/letsencrypt \ | ||
certbot/certbot certonly -d aerodata.uastech.co \ | ||
--standalone -m [email protected] --agree-tos | ||
``` | ||
|
||
```shell | ||
sudo openssl dhparam -out /root/nginx/dhparam.pem 4096 | ||
``` | ||
|
||
### /root/nginx/nginx.conf | ||
|
||
``` | ||
events { | ||
worker_connections 4096; | ||
} | ||
http { | ||
server { | ||
listen 80; | ||
server_name aerodata.uastech.co; | ||
return 301 https://$host$request_uri; | ||
} | ||
server { | ||
listen 443 ssl default deferred; | ||
server_name aerodata.uastech.co; | ||
ssl_certificate /etc/letsencrypt/live/aerodata.uastech.co/fullchain.pem; | ||
ssl_certificate_key /etc/letsencrypt/live/aerodata.uastech.co/privkey.pem; | ||
ssl_dhparam /etc/ssl/certs/dhparam.pem; | ||
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains"; | ||
ssl_trusted_certificate /etc/letsencrypt/live/aerodata.uastech.co/fullchain.pem; | ||
location / { | ||
proxy_pass http://host.docker.internal:8090; | ||
} | ||
} | ||
} | ||
``` | ||
|
||
```shell | ||
sudo docker run --restart always -d -p 80:80 -p 443:443 \ | ||
-v /root/nginx/letsencrypt:/etc/letsencrypt \ | ||
-v /root/nginx/dhparam.pem:/etc/ssl/certs/dhparam.pem \ | ||
-v /root/nginx/nginx.conf:/etc/nginx/nginx.conf \ | ||
--add-host=host.docker.internal:host-gateway \ | ||
--name proxy \ | ||
nginx:alpine | ||
``` | ||
|
||
## Cert renewal | ||
|
||
```shell | ||
docker stop proxy | ||
``` | ||
|
||
```shell | ||
docker run --rm -p 80:80 -p 443:443 \ | ||
-v /root/nginx/letsencrypt:/etc/letsencrypt \ | ||
certbot/certbot renew | ||
``` | ||
|
||
```shell | ||
docker start proxy | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
|
||
docker image build -t aerodata . | ||
docker container run -d -p 8090:8090 -v $(pwd)/aerodata:/app/aerodata aerodata | ||
docker container run -d --name aerodata -p 8090:8090 -v $(pwd)/aerodata:/app/aerodata aerodata |