๐ŸŒŠ DigitalOcean์˜ Ubuntu 18.04์—์„œ Let's Encrypt๋กœ Nginx๋ฅผ ๋ณดํ˜ธํ•˜๋Š” ๋ฐฉ๋ฒ•

5228 ๋‹จ์–ด ubuntulinux
1 ๋‹จ๊ณ„

Certbot ์„ค์น˜

sudo add-apt-repository ppa:certbot/certbot



sudo apt install python-certbot-nginx


2 ๋‹จ๊ณ„

Nginx ๊ตฌ์„ฑ ํ™•์ธ

sudo nano /etc/nginx/sites-available/example.com


/etc/nginx/sites-available/example.com

...
server_name example.com www.example.com;
...



sudo nginx -t



sudo systemctl reload nginx


3๋‹จ๊ณ„

๋ฐฉํ™”๋ฒฝ์„ ํ†ตํ•œ HTTPS ํ—ˆ์šฉ

sudo ufw status



Output
Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere                  
Nginx HTTP                 ALLOW       Anywhere                  
OpenSSH (v6)               ALLOW       Anywhere (v6)             
Nginx HTTP (v6)            ALLOW       Anywhere (v6)



sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'



sudo ufw status



Output
Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere
Nginx Full                 ALLOW       Anywhere
OpenSSH (v6)               ALLOW       Anywhere (v6)
Nginx Full (v6)            ALLOW       Anywhere (v6)


4๋‹จ๊ณ„

SSL ์ธ์ฆ์„œ ์–ป๊ธฐ

sudo certbot --nginx -d example.com -d www.example.com



Output
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
-------------------------------------------------------------------------------
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
-------------------------------------------------------------------------------
Select the appropriate number [1-2] then [enter] (press 'c' to cancel):



Output
IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/example.com/privkey.pem
   Your cert will expire on 2018-07-23. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le


5๋‹จ๊ณ„

Certbot ์ž๋™ ๊ฐฑ์‹  ํ™•์ธ

sudo certbot renew --dry-run

์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ