certbot

  • 無料でWEBサイトをhttpsにできる
  • 例の如くdocker-composeでイケる
...
  certbot:
    restart: "no"
    image: certbot/certbot:latest
    profiles: ["_"]
    volumes:
      - ./certbot/etc/:/etc/letsencrypt/
      - ./certbot/var/:/var/lib/letsencrypt/
      - ./certbot/public/:/public/  # webroot用のディレクトリ(nginxなどと共有する)
...
  • この設定をすれば,新しいドメインの証明書を取得するときに,下で紹介するコマンドを打つだけで良くなる
server {
  listen 80;
  location /.well-known/ {
    root /srv/http/certbot/;  # certbotサービスの/publicディレクトリをmountした場所を指定する
  }
  location / {
    return 301 https://$host$request_uri;
  }
}
docker-compose run certbot certonly --webroot -w /public -d <DOMAIN> --agree-tos
docker-compose run certbot renew
  • Last modified: 12 months ago