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?

CloudflareTunnelを使った公開の場合の仕組み

0
Posted at

概要

以下の記事で公開していた、Webサーバ公開するまでの仕組みを備忘録として残しておく。

1. なぜグローバルIPを持っていないのに公開できるのか?

結論: Cloudflare がプロキシとして代わりに公開しているから

通常、Webサイトを公開するには、外部からあなたのサーバーを見つけるための「住所(グローバルIP)」が必要。

ユーザー → www.example.com DNS → Cloudflare の DNS → Cloudflare の IP → トンネルを介したオリジンサーバ

という流れになる。

2. ドメインの流れ

  1. まずドメインレジストラからドメイン名を取得。例: example.com
  2. その後、ドメインのネームサーバーを Cloudflare のものに変更します。
    1. example.comを買った場所で、example.comのNSレコードを
      (いわゆるDNS委譲: ネームサーバーをCloudflareに向ける(管理権限を渡す))
    2. これにより、**「このドメインのことはCloudflareに聞いてね」**という状態になる対応していない形式のファイルです。
      対応していない形式のファイルです。
    3. https://zenn.dev/trans/articles/ef972043c090cb
    4. 今回自分はddns nowというサイトのNSレコードで設定した。
example.com NS  ns1.cloudflare.com
  1. 次に、自分が公開したいサブドメイン(例:www.example.com)に対して、
    CNAME を Cloudflare のエンドポイントに向ける
www.example.com CNAME hoge.cloudflare.net

これにより、Cloudflareのサーバは、www.example.comの問い合わせが来たら、hoge.cloudflare.netに返すという内容が生まれる。
このCNAME先はクラウドフレアのCDNであり、全世界に公開されている。

またこのサーバには、CloudflareTunnelを利用してオリジンサーバ(GIPのない手持ちのWebサーバ)と接続されている。Webからのアクセスが来た時にCloudflareのサーバがオリジンサーバにトンネル経由でコンテンツを取りに行くことで、アクセスが成立している。

スクリーンショット 2026-04-15 12.36.15.png

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?