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?

Let's Encrypt SSL証明書完全自動化ガイド:証明書の取得から更新まで完全ノーメンテナンス化

Last updated at Posted at 2025-09-16

Let's EncryptでSSL証明書を完全自動化する(2025年最新版)

2025年現在の公式推奨インストール方法

Let's Encryptの公式推奨はsnap版です。常に最新版が利用でき、セキュリティ更新も自動適用されます。

# snapパッケージマネージャーをインストール
sudo apt update && sudo apt install -y snapd

# snapコアを最新化
sudo snap install core; sudo snap refresh core

# 古いapt版certbotを削除(競合回避)
sudo apt-get remove certbot

# certbotをsnapでインストール
sudo snap install --classic certbot

# コマンドリンク作成
sudo ln -s /snap/bin/certbot /usr/bin/certbot

Nginx/Apache向け証明書の取得

基本的な証明書取得(自動設定込み)

# Nginx用
sudo certbot --nginx -d example.com -d www.example.com

# Apache用
sudo certbot --apache -d example.com -d www.example.com

証明書のみ取得(手動設定)

sudo certbot certonly --webroot -w /var/www/html -d example.com

ワイルドカード証明書(DNS認証)

複数サブドメインがある場合はワイルドカード証明書が便利です。

Cloudflare DNS認証の設定

# Cloudflareプラグインをインストール
sudo apt install python3-certbot-dns-cloudflare

# APIトークン用ディレクトリ作成
sudo mkdir -p /etc/letsencrypt/.secrets
sudo chmod 700 /etc/letsencrypt/.secrets

# 認証ファイル作成
sudo nano /etc/letsencrypt/.secrets/cloudflare.ini

cloudflare.ini:

dns_cloudflare_api_token = YOUR_API_TOKEN
# パーミッション設定
sudo chmod 600 /etc/letsencrypt/.secrets/cloudflare.ini

# ワイルドカード証明書取得
sudo certbot certonly \
  --dns-cloudflare \
  --dns-cloudflare-credentials /etc/letsencrypt/.secrets/cloudflare.ini \
  -d 'example.com' -d '*.example.com'

自動更新の確認

snap版は自動でsystemd timerを設定します。

# 更新テスト(実際には更新しない)
sudo certbot renew --dry-run

# タイマー確認
sudo systemctl list-timers | grep certbot

# 証明書の状態確認
sudo certbot certificates

トラブルシューティング

ポート80/443の開放確認

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

DNS伝播待ち

# DNS確認
dig example.com
nslookup example.com

まとめ

2025年現在、Let's Encryptの設定は以下がポイント:

  • snap版certbotが公式推奨
  • systemd timerで自動更新(設定不要)
  • ワイルドカード証明書はDNS認証必須
  • APIトークンはスコープ制限を推奨

より詳細な設定手順・エラー対処法はブログで解説
👉 Let's Encrypt SSL証明書完全自動化ガイド

ブログ記事では以下も詳しく解説:

  • 各種エラーの対処法
  • リバースプロキシ環境での設定
  • 証明書の手動更新方法
  • 複数ドメインの管理テクニック

#LetsEncrypt #SSL #HTTPS #certbot #自動化

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?