1
2

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.

cloudflare + caddy v2で SSL mode full (strict) をする方法

1
Posted at

これをしたい

SSL_TLS___mardigrasbeadsfactory_com___Account___Cloudflare_-_Web_Performance___Security.png

flexible(サイトに来る人 - SSL - cloudflare - plain - 自サーバー)

これだけでもまー良さそうではある。が、一応cloudflare自身もオススメしていないので、full (strict)に設定したい。

Cursor_and_End-to-end_HTTPS_with_Cloudflare_-Part_3__SSL_options–_Cloudflare_Help_Center.png

as a last resort (最終手段)

それぞれの違い

cf_ssl_settings.png

  • off 言うまでもなく何も防御なし
  • flexible 見る人からcloudflareまではSSL
  • full cloudflareから自サーバーまでもSSL(self-certificate)
  • full(strict) cloudflareから自サーバーまでもSSL(certificateはcloudflareから)

Caddyを使ってる

caddyは最初からlet's encryptでcertificateを用意してくれるので...cloudfareがドメイン管理してて、そっちでlet's encrypt使ってくれてるから、???
となる。

多分一番簡単なやり方

  1. まず、間違いなく80と443ポートはファイヤーウォールから外れていることを確認

  2. caddyはv2だ

  3. cloudflareの自ドメインで、SSL/TLS→origin server→create certificateと行く
    SSL_TLS___mardigrasbeadsfactory_com___Account___Cloudflare_-_Web_Performance___Security-2.png

  4. 何もせずにcreateすれば15年持つcertificateが作れる
    SSL_TLS___mardigrasbeadsfactory_com___Account___Cloudflare_-_Web_Performance___Security-4.png

  5. 出てきたcertificateとprivate keyを各ファイルにする
    /etc/ssl/certs/certificate.pem
    /etc/ssl/private/key.pem
    SSL_TLS___mardigrasbeadsfactory_com___Account___Cloudflare_-_Web_Performance___Security-6.png

  6. Caddyfileを書き換える

  7. caddy runする

  8. cloudflareのSSL modeをfull (strict)に切り替える(多分10秒ぐらいは待ったほうが良い)

Caddyfileを書き換え

example.com {
  tls /etc/ssl/certs/certificate.pem /etc/ssl/private/key.pem
  respond "Hello, world!"
}

参考:

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?