無料SSLサーバー証明書 Let's Encrypt インストール

この章を始める前に下記の設定が必要です
「Apache2 インストール」 or 「Nginx インストール」 「Apache2 バーチャルホスト 設定」 or 「Nginx バーチャルホスト 設定」
Certbotインストール
[root@centos ~]# wget https://dl.eff.org/certbot-auto
[root@centos ~]# chmod +x certbot-auto
[root@centos ~]# ./certbot-auto
・
・
・
総ダウンロード容量: 7.0 M
インストール容量: 20 M
Is this ok [y/d/N]: y ←yを入力してエンター(関連パッケージのインストール)
・
・
・
完了しました!
Upgrading certbot-auto 0.21.1 to 0.22.0...
Replacing certbot-auto...
Creating virtual environment...
Installing Python packages...
Installation succeeded.
Saving debug log to /var/log/letsencrypt/letsencrypt.log

How would you like to authenticate and install certificates?
-------------------------------------------------------------------------------
1: Apache Web Server plugin - Beta (apache)
2: Nginx Web Server plugin - Alpha (nginx)
-------------------------------------------------------------------------------
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2 ←Apacheの場合1、Nginxの場合2を入力してエンター(Webサーバーを選択)
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): postmaster@centos.orz ←メールアドレスを入力してエンター

-------------------------------------------------------------------------------
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-v01.api.letsencrypt.org/directory
-------------------------------------------------------------------------------
(A)gree/(C)ancel: A ←Aを入力してエンター(規約に同意)

-------------------------------------------------------------------------------
Would you be willing 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 EFF and
our work to encrypt the web, protect its users and defend digital rights.
-------------------------------------------------------------------------------
(Y)es/(N)o: N ←Nを入力してエンター(EFFにメールアドレスを登録しない)

Which names would you like to activate HTTPS for?
-------------------------------------------------------------------------------
1: centos.orz
2: virtual.centos.orz
-------------------------------------------------------------------------------
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1 ←1を入力してエンター(HTTPS化するアドレスを選択)
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for centos.orz
Waiting for verification...
Cleaning up challenges
Deployed Certificate to VirtualHost /etc/nginx/conf.d/virtualhost.conf for centos.orz

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
-------------------------------------------------------------------------------
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
-------------------------------------------------------------------------------
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1 ←1を入力してエンター(HTTPSへリダイレクトさせない)

-------------------------------------------------------------------------------
Congratulations! You have successfully enabled https://centos.orz

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=centos.orz
-------------------------------------------------------------------------------

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/centos.orz/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/centos.orz/privkey.pem
   Your cert will expire on 2018-06-03. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot-auto
   again with the "certonly" option. To non-interactively renew *all*
   of your certificates, run "certbot-auto renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le
ヒント
ドメインを複数設定する場合も同様に「./certbot-auto」を実行してください。
Let's Encryptの有効期限は3ヶ月なので期限が切れる前に更新する必要があります。
Let's Encrypt自動更新
[root@centos ~]# vi /etc/cron.monthly/certbot
#!/bin/sh

/root/certbot-auto renew --post-hook "systemctl restart nginx"
[root@centos ~]# chmod +x /etc/cron.monthly/certbot
ブラウザで確認 (https://ドメイン名/ にアクセス)

外部に公開する場合
プロトコル(TCP)ポート443番(HTTPS)を開放。
Home PageTop