コンテンツにスキップ

Cloudflare Tunnel

Cloudflare Tunnelとの統合を通じて、トラフィックをキーボードサーバーに安全なチャネルを介して送信し、キーボードサーバーを公衆インターネットにさらすことを避けることができます。


Before you begin

Supported platforms

Keyless has been tested on amd64 and arm architectures. The key server binary will likely run on all architectures that Go supports. Code support may exist for other CPUs too, but these other architectures have not been tested.

In addition to running on bare metal, the key server should run without issue in a virtualized or containerized environment. Care will need to be taken to configure ingress access to the appropriate TCP port and file system access to private keys (if using filesystem storage).

Supported operating systems

You will need to have a supported operating system (OS) to run Keyless. Supported operating systems include:

  • Ubuntu 14.04 LTS, 16.04 LTS, 18.04 LTS, 20.04 LTS, 22.04 LTS, 22.10
  • Debian 8, 9, 10, 11, 12
  • RHEL and CentOS 6, 7, 8, 9
  • Amazon Linux 1, 2

We strongly recommend that you use an operating system still supported by the vendor (still receiving security updates) as your key server will have access to your private keys.


ステップ1 - キーボードサーバーにcloudflaredをインストール

まず、キーボードサーバーにcloudflaredをインストールします。

This process differs depending on whether you are using the command line or the Cloudflare dashboard.


ステップ2 - トンネルを作成

次に、Cloudflare Tunnelを作成します。

This process differs depending on whether you are using the command line or the Cloudflare dashboard.


このステップでは、ネットワークに接続するオプションを選択し、キーボードサーバーのプライベートIPアドレスを使用する必要があります。

トンネルを作成した後、Cloudflare APIを使用してtunnel routesをリストし、次の値を将来のステップのために保存します:

  • "virtual_network_id"
  • "network"

ステップ3 - キーレスSSL証明書をアップロード

Before your key servers can be configured, you must next upload the corresponding SSL certificates to Cloudflare’s edge. During TLS termination, Cloudflare will present these certificates to connecting browsers and then (for non-resumed sessions) communicate with the specified key server to complete the handshake.

Upload certificates to Cloudflare with only SANs that you wish to use with Cloudflare Keyless SSL. All Keyless SSL hostnames must be proxied.

You will have to upload each certificate used with Keyless SSL.

APIを使用してキーレス証明書をアップロードするには、"tunnel"オブジェクトを含むPOSTリクエストを送信します。

"tunnel": {
"vnet_id": "<VIRTUAL_NETWORK_ID>",
"private_ip": "<NETWORK>"
}

ステップ4 - キーボードサーバーを設定してアクティブ化

Finally, you need to install the key server on your infrastructure, populate it with the SSL keys of the certificates you wish to use to terminate TLS at Cloudflare’s edge, and activate the key server so it can be mutually authenticated.

Install

These steps are also at pkg.cloudflare.com.

Debian/Ubuntu packages

Debian or Ubuntu
sudo mkdir -p --mode=0755 /usr/share/keyrings
curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg | sudo tee /usr/share/keyrings/cloudflare-main.gpg >/dev/null
# Add this repo to your apt repositories
echo 'deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/gokeyless buster main' | sudo tee /etc/apt/sources.list.d/cloudflare.list
# install gokeyless
sudo apt-get update && sudo apt-get install gokeyless

RHEL/CentOS packages

Use either of the following examples to install the gokeyless package for RHEL or CentOS.

Option 1

RHEL or CentOS (version lower than 8)
sudo yum makecache
sudo yum-config-manager --add-repo https://pkg.cloudflare.com/gokeyless.repo && sudo yum-config-manager --setopt=gokeyless-stable.gpgkey=https://pkg.cloudflare.com/cloudflare-ascii-pubkey.gpg --save
sudo yum install gokeyless

Option 2

RHEL or CentOS (version 8 or higher)
sudo dnf install dnf-plugins-core && dnf clean all
sudo dnf config-manager --add-repo https://pkg.cloudflare.com/gokeyless.repo
sudo dnf install gokeyless

Configure

Add your Cloudflare account details to the configuration file located at /etc/keyless/gokeyless.yaml:

  1. Set the hostname of the key server, for example, keyserver.keyless.example.com. This is also the value you entered when you uploaded your keyless certificate and is the hostname of your key server that holds the key for this certificate.
  2. Set the Zone ID (found on Overview tab of the Cloudflare dashboard).
  3. Set the Origin CA API key.

Populate keys

Install your private keys in /etc/keyless/keys/ and set the user and group to keyless with 400 permissions. Keys must be in PEM or DER format and have an extension of .key:

Terminal window
ls -l /etc/keyless/keys
-r-------- 1 keyless keyless 1675 Nov 18 16:44 example.com.key

When running multiple key servers, make sure all required keys are distributed to each key server. Customers typically will either use a configuration management tool such as Salt or Puppet to distribute keys or mount /etc/keyless/keys to a network location accessible only by your key servers. Keys are read on boot into memory, so a network path must be accessible during the gokeyless process start/restart.

Activate

To activate, restart your keyless instance:

  • systemd: sudo service gokeyless restart
  • upstart/sysvinit: sudo /etc/init.d/gokeyless restart

If this command fails, try troubleshooting by checking the logs.