Conoha Centos7 無料SSL letsencrypt 導入

 WWWサーバはできたので、無料のSSLを導入してみる。

公式サイト
https://letsencrypt.jp/


公式サイトにあったCentos7の手順

sudo yum install epel-release 
sudo yum install certbot python-certbot-apache


apacheじゃないならpython-certbot-apacheはいらないとのこと。

実際やってみましょう。というかこの次何?


手順



1.インストール
sudo yum install certbot


2.コマンドを入力
sudo certbot certonly --webroot --webroot-path /var/www/html/ -d example.jp -d www.example.jp

メールアドレスを聞かれるので入力。


3.webサーバがうごいてるとだめなそーなので。
webroot webroot-pathを指定してると動いていてもいけると書いてあるのですが。。。。

sudo systemctl stop nginx

もう一度 2のコマンドを投入


4.443が開いてねーぞってことなので、iptables修正して再度 2のコマンドを投入

5.止めたwebサーバを起動

sudo systemctl start nginx

6.それっぽくちゃんとSSLの設定をする。


 # Settings for a TLS enabled server.
#
    server {
        listen       443 ssl http2 default_server;
        listen       [::]:443 ssl http2 default_server;
        server_name  _;
        root         /usr/share/nginx/html/def;

        ssl_certificate "/etc/letsencrypt/live/example.jp/fullpath.pem";
        ssl_certificate_key "/etc/letsencrypt/live/example.jp/privkey.pem";
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;
        ssl_ciphers HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers on;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
        location / {
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

7. 更新を試してみる。
systemctl stop nginx
certbot renew --force-renew
systemctl start nginx

それっぽいログがでたらおめでとう。

8. 自動更新シェルをつくる
中身は↓、cronで週一ぐらい?

#!/bin/sh
systemctl stop nginx
certbot renew
systemctl start nginx

このブログの人気の投稿

laragonのphpmyadminでエラーが出た。

メールサーバの移行(自宅→レンタル) 検討

Conoha VPS Centos7へTeamspeak3の導入