開発

ngrokの代わりにcloudflaredを使ってみよう

はじめに

Cloudflareでcloudflaredというクライアントで動いているサービスを公開できるアプリケーションがあるみたいです。ngrokの代わりなりそうなものです。特にユーザー登録などないので気軽に使えるのでないでしょうか。

Downloads · Cloudflare Zero Trust docs
Downloads · Cloudflare Zero Trust docs

Cloudflare Tunnel requires the installation of a lightweight server-side daemon, cloudflared, to con ...

developers.cloudflare.com

試してみよう

Ubuntuにインストールしてみましょう。

# wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
# dpkg -i cloudflared-linux-amd64.deb

公開するサービスをインストールします。

# apt install nginx

公開します。

# cloudflared tunnel --url localhost:80
2023-03-17T06:41:56Z INF Thank you for trying Cloudflare Tunnel. Doing so, without a Cloudflare account, is a quick way to experiment and try it out. However, be aware that these account-less Tunnels have no uptime guarantee. If you intend to use Tunnels in production you should use a pre-created named tunnel by following: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps
2023-03-17T06:41:56Z INF Requesting new quick Tunnel on trycloudflare.com...
2023-03-17T06:41:58Z INF +--------------------------------------------------------------------------------------------+
2023-03-17T06:41:58Z INF | Your quick Tunnel has been created! Visit it at (it may take some time to be reachable): |
2023-03-17T06:41:58Z INF | https://feat-blvd-costume-advanced.trycloudflare.com |
2023-03-17T06:41:58Z INF +--------------------------------------------------------------------------------------------+
2023-03-17T06:41:58Z INF Cannot determine default configuration path. No file [config.yml config.yaml] in [~/.cloudflared ~/.cloudflare-warp ~/cloudflare-warp /etc/cloudflared /usr/local/etc/cloudflared]
2023-03-17T06:41:58Z INF Version 2023.3.1
2023-03-17T06:41:58Z INF GOOS: linux, GOVersion: go1.19.3, GoArch: amd64
2023-03-17T06:41:58Z INF Settings: map[protocol:quic url:localhost:80]
2023-03-17T06:41:58Z INF Generated Connector ID: d5e41040-aec3-4837-95b5-3f2f7524d61a
2023-03-17T06:41:58Z INF Initial protocol quic
2023-03-17T06:41:58Z INF ICMP proxy will use 10.5.0.4 as source for IPv4
2023-03-17T06:41:58Z INF ICMP proxy will use fe80::222:48ff:fee6:e134 in zone eth0 as source for IPv6
2023-03-17T06:41:58Z INF cloudflared will not automatically update if installed by a package manager.
2023-03-17T06:41:58Z INF Starting metrics server on 127.0.0.1:44575/metrics
2023/03/17 06:41:58 failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 416 kiB). See https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size for details.
2023-03-17T06:41:59Z INF Connection 05ca0b5b-c252-4964-af5c-a65047d8e9e6 registered with protocol: quic connIndex=0 ip=198.41.200.23 location=KIX
2023-03-17T06:41:59Z INF Connection ff7bd2d6-90c6-493f-a704-891d0fff7b0f registered with protocol: quic connIndex=1 ip=198.41.192.7 location=NRT
2023-03-17T06:42:00Z INF Connection c8230e25-e80e-4c62-b7d7-3874c6ac3174 registered with protocol: quic connIndex=2 ip=198.41.200.53 location=KIX
2023-03-17T06:42:01Z INF Connection 83c8744c-e8dd-44fc-bc3e-9d262e400b63 registered with protocol: quic connIndex=3 ip=198.41.192.27 location=NRT

 

あとは表示されたURLにアクセスするだけです。

まとめ

Cloudflareで無償で利用できるソフトウェアなので検証などで利用できるのではないでしょうか。

 

-開発