|
| 1 | +# Let's encrypt |
| 2 | + |
| 3 | +## Introduction |
| 4 | +To start off, I run an NGINX web server. <br/> |
| 5 | +This could be running anywhere in the cloud. <br/> |
| 6 | + |
| 7 | +``` |
| 8 | +docker run -it -p 80:80 nginx bash |
| 9 | +
|
| 10 | +# get my public IP for this server |
| 11 | +curl ifconfig.co |
| 12 | +
|
| 13 | +# lets get out of the container |
| 14 | +exit |
| 15 | +
|
| 16 | +``` |
| 17 | + |
| 18 | +Now that we have the public IP for our server, lets start it up again <br/> |
| 19 | +This time, without bash <br/> |
| 20 | +We should be able to access it in the browser <br/> |
| 21 | + |
| 22 | +``` |
| 23 | +docker run -it -p 80:80 nginx |
| 24 | +``` |
| 25 | + |
| 26 | +In the video, we create a DNS record and point it to the IP of our server <br/> |
| 27 | + |
| 28 | +## Certbot |
| 29 | + |
| 30 | +The [docs](https://certbot.eff.org/) |
| 31 | + |
| 32 | +To build certbot, i simply change directory and build my certbot container <br/> |
| 33 | + |
| 34 | +``` |
| 35 | +cd .\security\letsencrypt\introduction\ |
| 36 | +
|
| 37 | +docker build . -t certbot |
| 38 | +
|
| 39 | +docker run -it --rm --name certbot ` |
| 40 | +-v ${PWD}:/letsencrypt ` |
| 41 | +-v ${PWD}/certs:/etc/letsencrypt ` |
| 42 | +certbot bash |
| 43 | +
|
| 44 | +``` |
| 45 | + |
| 46 | +## NGINX |
| 47 | + |
| 48 | +We've customised our `nginx.conf` as shown in the video <br/> |
| 49 | + |
| 50 | +Run this NGINX, we mount the shared folder that certbot will use: |
| 51 | + |
| 52 | +``` |
| 53 | +cd .\security\letsencrypt\introduction\ |
| 54 | +
|
| 55 | +docker run -it --rm --name nginx ` |
| 56 | +-v ${PWD}/nginx.conf:/etc/nginx/nginx.conf ` |
| 57 | +-v ${PWD}:/letsencrypt ` |
| 58 | +-v ${PWD}/certs:/etc/letsencrypt ` |
| 59 | +-p 80:80 ` |
| 60 | +-p 443:443 ` |
| 61 | +nginx |
| 62 | +
|
| 63 | +``` |
| 64 | + |
| 65 | +## Issue certificate |
| 66 | + |
| 67 | +In certbot, generate our cert: |
| 68 | + |
| 69 | +``` |
| 70 | +certbot certonly --webroot |
| 71 | +
|
| 72 | +# webroot is the folder we mounted: /letsencrypt |
| 73 | +
|
| 74 | +# certificate outputs under etc/letsencrypt/live/** |
| 75 | +# since we share this volume with our webserver, we dont need to copy |
| 76 | +# certificates across. |
| 77 | +
|
| 78 | +IMPORTANT NOTES: |
| 79 | + - Congratulations! Your certificate and chain have been saved at: |
| 80 | + /etc/letsencrypt/live/marcel.guru/fullchain.pem |
| 81 | + Your key file has been saved at: |
| 82 | + /etc/letsencrypt/live/marcel.guru/privkey.pem |
| 83 | + Your cert will expire on 2020-12-03. To obtain a new or tweaked |
| 84 | + version of this certificate in the future, simply run certbot |
| 85 | + again. To non-interactively renew *all* of your certificates, run |
| 86 | + "certbot renew" |
| 87 | + - Your account credentials have been saved in your Certbot |
| 88 | + configuration directory at /etc/letsencrypt. You should make a |
| 89 | + secure backup of this folder now. This configuration directory will |
| 90 | + also contain certificates and private keys obtained by Certbot so |
| 91 | + making regular backups of this folder is ideal. |
| 92 | + - If you like Certbot, please consider supporting our work by: |
| 93 | +
|
| 94 | + Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate |
| 95 | + Donating to EFF: https://eff.org/donate-le |
| 96 | +
|
| 97 | +``` |
| 98 | + |
| 99 | +## Renewal |
| 100 | + |
| 101 | +To do a dry run of cert renewal: |
| 102 | + |
| 103 | +``` |
| 104 | +certbot renew --dry-run |
| 105 | +``` |
| 106 | + |
| 107 | +Reload our NGINX web server if the certs change: |
| 108 | + |
| 109 | +``` |
| 110 | +docker exec -it nginx sh -c "nginx -s reload" |
| 111 | +``` |
| 112 | + |
| 113 | +Checkout the Certbot [docs](https://certbot.eff.org/instructions) for more details |
0 commit comments