letsencrypt

概要

letsencryptを使ってSSL証明書を設置する手順です。

手順

# cd /usr/local/
# git clone https://github.com/certbot/certbot
# cd certbot/
# ./certbot-auto -n
# ./certbot-auto certonly --webroot \
-w /var/www/example -d example.com \
-m sample@example.com \
--agree-tos -n

webサーバーの設定

apacheの場合(CentOS6(sysvinit),apache2.2の場合)

下記設定で80番にきた受付をすべてhttpsへリダイレクトさせる。

# vim httpd.conf <-- 80番の設定
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule /.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# vim ssl.conf
DocumentRoot  <-- 80番の設定と同じ
ServerName <-- 80番の設定と同じ

下記へ変更する
SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCACertificateFile /etc/letsencrypt/live/example.com/chain.pem

# serivce httpd configtest
# service httpd graceful

自動更新設定

# crontab -e
00 05 01 * * /usr/local/certbot/certbot-auto renew --force-renewal && /bin/systemctl reload httpd

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2022-06-30 (木) 01:40:11