4
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 1 year has passed since last update.

traefikにLet's Encryptを設定する

Last updated at Posted at 2021-08-27

上記の設定が出来ていることが前提となります。

■traefik.ymlの変更

/tmp/traefik.yml
# 変更前
certificatesResolvers:
  default:
    acme:
      email: system@test.local
      storage: acme.json
      httpChallenge:
        entryPoint: web
# 変更後
certificatesResolvers:
  default:
    acme:
      email: system@test.local
      storage: acme.json
+      tlsChallenge: {}
+      # ステージングでの確認はURLが異なります
+      caServer: https://acme-v02.api.letsencrypt.org/directory
      httpChallenge:
        entryPoint: web

■docker-compose-app.yml

docker-compose-app.yml
# 変更前
      # 443設定
      - traefik.http.routers.test-app-test-secure.rule=Host(`apptest.local`))
      - traefik.http.routers.test-app-test-secure.entrypoints=secure
      - traefik.http.routers.test-app-test-secure.tls=true
      - traefik.http.routers.test-app-test-secure.service=test-app-test-secure-service
      - traefik.http.services.test-app-test-secure-service.loadbalancer.server.port=80
# 変更後
      # 443設定
      - traefik.http.routers.test-app-test-secure.rule=Host(`apptest.local`))
      - traefik.http.routers.test-app-test-secure.entrypoints=secure
      - traefik.http.routers.test-app-test-secure.tls=true
+      # certresolverを追加
+      - traefik.http.routers.test-app-test-secure.tls.certresolver=default
      - traefik.http.routers.test-app-test-secure.service=test-app-test-secure-service
      - traefik.http.services.test-app-test-secure-service.loadbalancer.server.port=80

■SSL証明書対応について

上記の2ファイルを少し変更するだけで対応できます。

設定変更後、traefikコンテナの再起動が必要になります。
caServerを切り替える際、コンテナ内の「acme.json」を削除する必要があります。

■関連記事

4
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
4
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?