letsencrypt で SSL を有効にする

Let’s Encrypt は、無料で自動化されたオープン CA (証明機関) です。これを利用して、nginx によって提供される Web アプリケーションへの SSL アクセスを有効にしましょう。

Download certbot tool

$ wget https://dl.eff.org/certbot-auto
$ chmod a+x certbot-auto
$ ./certbox-auto

Get certificate for your domain name

$ ./certbot-auto certonly --nginx -d <domain.name>

Find and verify that privkey.pem and fullchain.pem exists

/etc/letsencrypt/live/<domain.name>/privkey.pem
/etc/letsencrypt/live/<domain.name>/fullchain.pem

Config on nginx

server {
    listen   80;
    listen   443 ssl;
    server_name  domain.name;
    ssl_certificate  /etc/letsencrypt/live/domain.name/fullchain.pem;
    ssl_certificate_key  /etc/letsencrypt/live/domain.name/privkey.pem;
    location / {
        proxy_pass http://0.0.0.0:8080;
        include /etc/nginx/proxy_params;
    }
}

Renew or update certificate

./certbot-auto renew

参考文献

ssl