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

More than 1 year has passed since last update.

cloudflaredでトンネルを作る手順

Posted at

cloudflaredでプライベートなサーバーをWeb公開することができます。

テンポラリのURLを生成する用途で紹介されることも多いですが、固定のドメインも作ることができます。

以下手順

cloudflared tunnel login
  • これで~./cloudflared/cert.pemが作られる
  • ログインする際にどのドメインでURLをつくるかを選ぶ
cloudflared tunnel create [トンネル名]

このタイミングで~./.cloudflared/[uuid].json が作られる
トンネルを作り直す時には.jsonを削除するのではなく、後述のトンネル削除のコマンドを使う。

cloudflared tunnel route dns [トンネル名] [サブドメイン]

このコマンドで、サブドメインが新規に作られ、トンネルに接続される

cloudflared tunnel run --url localhost:8080 [トンネル名]

このコマンドで、ローカルの8080ポートが外部に公開される

ここからが番外編

  • やりなおしたい時がちょっと大変
  • トンネルができたかどうかが不安なときには、.jsonファイルが作られていることと、cloudflared tunnel list でトンネルが確かに作られてることを確認
  • その上でcloudflared tunnel delete [トンネル名] で削除してからcreateをもう一回やりなおす必要がある
  • さらにトンネルを作り直すと、サブドメインとの関連付けも再度必要になるためcloudflared tunnel route dns もやり直す必要があるが、残念ながらtunnel route dnsの削除や更新をするコマンドがないため、Webコンソールからサブドメインを一度削除する必要がある
2
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
2
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?