公式ドキュメント
https://letsencrypt.jp/docs/using.html
letsencryptをインストール
git clone https://github.com/letsencrypt/letsencrypt.git cd letsencrypt ./letsencrypt-auto --help
設定する
./letsencrypt-auto certonly --webroot -w /var/www/html/hoge.com -d hoge.com --email mail@hoge.com
/etc/nginx/conf.d/default.confを編集する。
# HTTP を HTTPS へリダイレクト
server {
listen 80;
server_name hoge.com;
return 301 https://$host$request_uri;
}
# HTTPS サーバの設定
server {
listen 443 ssl;
server_name hoge.com;
ssl_certificate /etc/letsencrypt/live/hoge.com/cert.pem;
ssl_certificate_key /etc/letsencrypt/live/hoge.com/privkey.pem;
root /var/www/html/hoge.com;
access_log /var/log/nginx/ssl-access.log main;
#その他いろいろな設定
}