前準備
Let’s Encryptを利用する場合にドメインでIPアドレスが正引き出来ることが前提条件となっているので正引きできることを確認
hostコマンドのインストール # yum install bind-utils 正引きの確認 # host www.hogehoge.com www.hogehoge.com has address 111.222.333.444 HTTPS 443ポートの開放 # firewall-cmd --add-port=443/tcp --permanent ファイヤーウォールの再起動 # firewall-cmd --reload 443ポート開放の確認 # firewall-cmd --list-all
Let’s Encryptのインストール
epelレポジトリのインストール # yum install epel-release epelレポジトリのインストール後の確認 $ yum list installed | grep epel certbotのインストール # yum install certbot certbotのインストール後の確認 $ yum list installed | grep certbot certbotのインストール場所の確認 $ which certbot
certbotコマンドの実行
# certbot certonly --webroot -w /usr/share/nginx/hogehoge/ -d www.hogehoge.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must agree in order to register with the ACME server at https://acme-v02.api.letsencrypt.org/directory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (A)gree/(C)ancel: Aでenter - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you be willing, once your first certificate is successfully issued, to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Nでenter 「Congratulations」と表示されたら処理の完了 サーバー証明書ファイルの確認 # cd /etc/letsencrypt/live/www.hogehoge.com
dhparamコマンドの実行
dhparam用ファイル保存用ディレクトリ作成 # mkdir /etc/nginx/ssl opensslコマンドでファイル作成 # openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
confファイルの修正
server { listen 80; server_name www.hogehoge.com; rewrite ^ https://$server_name$request_uri? permanent; } server { listen 443 ssl; server_name www.hogehoge.com; access_log /var/log/nginx/hogehoge-access.log main; error_log /var/log/nginx/hogehoge-error.log; root /usr/share/nginx/hogehoge; ssl_certificate /etc/letsencrypt/live/www.hogehoge.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/www.hogehoge.com/privkey.pem; ssl_session_timeout 1d; ssl_session_cache shared:SSL:50m; ssl_session_tickets on; ssl_dhparam /etc/nginx/ssl/dhparam.pem; ssl_protocols TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { index index.php index.html index.htm; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
confファイル保存後の書式エラー確認
書式のエラーチェック # nginx -t nginx再起動 # systemctl restart nginx
ブラウザで確認
「https://www.hogehoge.com/」
にアクセスして鍵マーク、証明書の確認