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 3 years have passed since last update.

snapd で certbot ssl letsencrypt

Last updated at Posted at 2021-12-19

snapd をインスコ


dnf --enablerepo=epel -y install snapd
ln -s /var/lib/snapd/snap /snap
echo 'export PATH=$PATH:/var/lib/snapd/snap/bin' > /etc/profile.d/snap.sh
systemctl enable --now snapd.service snapd.socket

snap install core
snap refresh core

snapd まで ok

centbot をインスコ


snap install --classic certbot
ln -s /snap/bin/certbot /usr/bin/certbot
ls -la /usr/bin/certbot
ls -la /snap/bin/certbot

certbot --version//バージョンが表示されてりゃOK

#certbot 実行

以下をやって設問に答えていこう。


certbot --nginx

すると勝手に default.conf が変わって SSL 接続が可能になる。

参考までに。


server {
    server_name your.club;
    root   /var/www/html/yamada/;
    index index.php index.html index.htm;



         location ~ \.php$ {

       fastcgi_pass   unix:/var/run/php-fpm/www.sock;

       fastcgi_index  index.php;

       fastcgi_param  SCRIPT_FILENAME /var/www/html/yamada$fastcgi_script_name;
        include        fastcgi_params;

 }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/your.club/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/your.club/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = twikon.club) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    server_name your.club;
    return 404; # managed by Certbot


}



#自動更新の設定

一応テスト


certbot renew --dry-run

まぁ、動きそうかな?

cron用 ログ・ファイルを作っておいて

/var/log/mycron.log

tekitou


#cron を設定

毎月 1日の1時0分に実行

cron.txt

# SSL自動更新
0 1 1 * * certbot renew --renew-hook "systemctl restart nginx" > /var/log/mycron.log 2>&1



crontab cron.txt

これでOK!

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?