LoginSignup
7
8

More than 3 years have passed since last update.

CentOS 7 の Nginx に Let's Encrypt で SSL を自動設定する

Posted at

Nginx をセットアップした CentOS 7 で Let's Encrypt の SSL を Certbot ACME クライアントで自動取得および自動設定する手順の解説。

リポジトリの導入

yum epel-release

certbot パッケージは EPEL リポジトリで利用可能。

Certbot と Nginx プラグインのインストール

yum certbot python2-certbot-nginx

2019年2月7日リリースの Certbot 0.31.0 がインストールされる。
epel-testing リポジトリを利用すると、2019年5月7日リリースの 0.34.2 がインストールされる。

SSL 証明書の取得

certbot \
  --nginx \
  --agree-tos \
  --domain example.jp \
  --email 'admin@example.jp' \
  --no-eff-email

certbot コマンドのサブコマンドを省略するとデフォルトの run になる。
Nginx の設定ファイルまで自動設定する場合は certonly および --standalone--webroot を指定しない。

--nginx オプションは Nginx プラグイン (python2-certbot-nginx パッケージ) がのインストールが必要。

--agree-tos オプションは ACME サーバーの Subscriber Agreement への同意。

--no-eff-email オプションは EFF 等にメールアドレスを共有しない。共有する場合は代わりに --eff-email オプションを指定する。

自動更新の設定

systemctl start certbot-renew.timer
systemctl enable certbot-renew.timer
systemctl list-timers --all

Cron ではなく systemd の Timer を利用して自動更新を設定する。

7
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
8