# Set up a Cloudflare tunnel for the Salto Space API
> Create a Cloudflare tunnel, publish SHIP through it, and restrict access so the Salto IDM Connect Space API can reach Salto Space.


A Cloudflare tunnel gives SHIP (Salto Host Interface Protocol) a stable public host name without opening inbound ports on your firewall.
A small program in your network, the Cloudflare connector (`cloudflared`), opens an encrypted, outbound-only connection to Cloudflare, and Cloudflare forwards requests for the host name to SHIP.

This guide covers route 1 of [Connect Salto Space to the Space API](/idm/connect/space-api/connect-salto-space#route-1-cloudflare-tunnel).
The tunnel belongs to your Cloudflare account, and you manage it there.

{{% info-panel %}}
Cloudflare changes its dashboard from time to time, so the names in this guide can differ from what you see.
If they do, follow [Create a tunnel](https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/get-started/create-remote-tunnel/) in the Cloudflare documentation.
To watch the setup, see [Salto Space remote access with Cloudflare Tunnels](https://www.youtube.com/watch?v=aZaQxDffPCw).
{{% /info-panel %}}

## Before you begin {#before-you-begin}

Make sure you have the following:

- SHIP enabled in Salto Space with the **HTTP(S)** transport and authentication.
See [Enable SHIP in Salto Space](/idm/connect/space-api/connect-salto-space#step-1-enable-ship-in-salto-space).
- A Cloudflare account with a domain added to it.
- Cloudflare Zero Trust activated in that account, which step 3 uses.
The Zero Trust Free plan covers this setup at no cost, but Cloudflare asks you to register a payment method, such as a credit card, when you activate it.
- Administrator access to a server in your network that can reach the SHIP port, such as the Salto Space server itself.
Cloudflare provides the connector for Windows, Linux, and macOS.
- A firewall that allows outbound connections from that server to Cloudflare on port `7844`, over TCP and UDP.
See [Cloudflare Tunnel with firewall](https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/configure-tunnels/tunnel-with-firewall/) for the destinations to allow.

## Step 1: Create the tunnel and install the connector {#step-1-create-the-tunnel-and-install-the-connector}

1. In the Cloudflare dashboard, go to **Networking** > **Tunnels**.
2. Select **Create Tunnel** and enter a name for the tunnel.
3. Choose the operating system of your server and copy the installation command that Cloudflare shows.
The command contains the connector token, which links the connector to your Cloudflare account, so keep it private.
4. On the server, open a terminal as an administrator and run the command.
On Windows, download and run the installer from the same page first, then run the command in a command prompt that you opened as an administrator.
5. Wait until Cloudflare shows that the tunnel is connected, then select **Continue**.

Keep the server and the connector running, because the tunnel works only while the connector runs.

## Step 2: Publish SHIP through the tunnel {#step-2-publish-ship-through-the-tunnel}

1. Go to **Networking** > **Tunnels** and select your tunnel.
2. On the **Routes** tab, select **Add route**, then select **Published application**.
3. Enter a subdomain and select your **Domain**.
Together they form the public host name of SHIP, for example `ship.example.com`.
4. In **Service URL**, enter the protocol, address, and port of SHIP as the connector reaches it:
    - `http://localhost:8100` if the connector runs on the Salto Space server and SHIP uses port `8100`.
    - `http://SPACE_SERVER:8100` if the connector runs on another server, where `SPACE_SERVER` is the internal address of the Salto Space server.
5. Select **Add route**.

If SHIP uses HTTPS, enter `https://` in the **Service URL**.
If the connector doesn't trust the SHIP certificate, for example because it's self-signed, open **Additional application settings** > **TLS** in the route and turn on **Disable TLS certificate verification**.
Cloudflare still encrypts the connection between the Space API and Cloudflare with its own certificate.
See [Origin configuration parameters](https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/configure-tunnels/origin-parameters/) in the Cloudflare documentation.

{{% warning-panel %}}
After this step, anyone on the internet can reach SHIP at the public host name.
Restrict access in step 3 before you share the host name.
{{% /warning-panel %}}

## Step 3: Allow only the Space API {#step-3-allow-only-the-space-api}

The Space API connects from one address, the [Space API address](/idm/connect/space-api/connect-salto-space#key-terms).
Use Cloudflare Access, which is part of Cloudflare Zero Trust, to block every other address.
Access policies deny everything that no policy allows, so one policy for the Space API address is enough:

1. In the Cloudflare dashboard, go to **Zero Trust** > **Access controls** > **Applications**.
If Zero Trust isn't active yet, Cloudflare asks you to activate a plan first.
Choose **Zero Trust Free** and register a payment method.
Cloudflare doesn't charge for this plan.
2. Select **Create new application**, then **Self-hosted and private**, and continue.
3. Under **Destinations**, select **Add public hostname** and enter the subdomain and domain of the public host name from step 2.
4. Under **Access policies**, select **Create new policy** and set the following values:
    - **Policy Name**: a name of your choice, for example `Space API`.
    - **Action**: **Bypass**, which lets the request through without a login page.
    The Space API can't complete an interactive login.
    - **Include**: the **IP ranges** selector with the value `20.73.151.133`.
5. Select **Save policy**, then **Create**.

Cloudflare Access doesn't log the requests that a **Bypass** policy lets through.
See [Access policies](https://developers.cloudflare.com/cloudflare-one/access-controls/policies/) in the Cloudflare documentation for the policy options.
Keep SHIP authentication enabled as well, because the access policy and the SHIP credentials protect SHIP together.

## Step 4: Share the host name with Salto {#step-4-share-the-host-name-with-salto}

Send the public host name and the SHIP credentials to Salto.
See [Share the connection details](/idm/connect/space-api/connect-salto-space#step-3-share-the-connection-details) for what to send and how to send it securely.

