0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

さくらVPSでサーバ構築(CentOS7.x)その2

0
Last updated at Posted at 2019-12-03

let's encryptでSSL証明書を発行

Let's encryptのコマンドの導入

# curl https://dl.eff.org/certbot-auto -o /usr/bin/certbot-auto
# chmod 700 /usr/bin/certbot-auto

証明書の必要な情報は
サーバのdocument root、ドメイン名、メールアドレス

# certbot-auto certonly --webroot -w /var/www/html/sub1 -d sub1.domain.com

以下のフォルダにpemファイルが生成される。フォルダはドメイン名

/etc/letsencrypt/live/sub1.domain.com/
cert.pem
chain.pem
fullchain.pem
privkey.pem

nginxのconfファイルにsslの設定行を追加

/etc/nginx/conf.d/sub1.conf
server {
    listen 80;

}
sever {
    listen 443 ssl;

    ssl_certificate     /etc/letsencrypt/live/sub1.domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/sub1.domain.com/privkey.pem;
}

nginxを再起動してブラウザでアクセス(httpsで)。

SSL証明書の更新

Let's encryptの証明書は3ヶ月で切れるので
再取得のスクリプトをcronで更新する。

vi /etc/cron.d/letsencrypt

/etc/cron.d/letsencrypt
00 16 * * 0 root /usr/bin/certbot-auto renew --post-hook "systemctl restart nginx"

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?