Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

0
1

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.

DNSroboCertを使ってDNS認証による簡単Let's Encrypt証明書自動更新

Last updated at Posted at 2021-07-07

Let's Encryptでは、http://<your-domain>/.well-known/acme-challengeにファイルを置いてドメイン所有権を確認する方法がよく取られますが、DNS認証でもドメイン認証することが可能です。

DNSroboCertでは、Lexicon という有名DNSプロバイダーのAPIを操作可能なライブラリを使って設定ファイルとDockerで80番ポートを開けたりインターネットに一時ファイルを公開せずに簡単にLet's Encrypt証明書の自動更新環境が作れます。

サポートしているDNSプロバイダーはこちら。
https://dnsrobocert.readthedocs.io/en/latest/providers_options.html#providers-options

使い方

以下にサンプルを用意しました。
https://github.com/naoa/ssl-with-dnsrobocert

非常にシンプルでDNSプロバイダーのトークンを取得し、configファイルにDNSプロバイダーの情報とドメインを記載し、Dockerで立ち上げるだけです。

以下のファイルの<your-email>, <your-dns-provider>, <your-dns-provider-token>, <your-domain>を書き換えます。

dnsrobocert/config.yml
draft: false

acme:
  email_account: <your-email>
  staging: false

profiles:
  - name: dns_profile
    provider: <your-dns-provider> # choose your dns provider https://dnsrobocert.readthedocs.io/en/latest/providers_options.html#providers-options
    provider_options:
      auth_token: <your-dns-provider-token>

certificates:
  - domains:
      - <your-domain>
    profile: dns_profile
  • docker-composeで起動します。
    ちなみに、DNS認証時には、自動的にDNSのゾーンにTXTレコードが追加されていることが確認できます。
docker-compose up -d
docker-comopse.yml
version: '3'
services:
  dnsrobocert:
    image: adferrand/dnsrobocert
    container_name: dnsrobocert
    volumes:
      - /etc/letsencrypt:/etc/letsencrypt
      - ./dnsrobocert:/etc/dnsrobocert
    restart: always

これにより、/etc/letsencrypt/liveに証明書ができるのでそれをnginx等に利用することができます。

configファイルとdocker-composeで非常にシンプルに実現できるので、わざわざマルチホストにしたいという意図がなければ、nginx-proxyを使った方法よりシンプルに他のWebアプリ用のDockerに連携できそうです。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?