> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/gateway/guides/reverse-proxies/ngrok.md). Agents can also search and read this documentation through its [MCP server](https://docs.devolutions.net/~gitbook/mcp).

# Ngrok

Reach Devolutions Gateway from the internet through its built-in ngrok tunnels: installer options, gateway.json settings, registration.

Devolutions Gateway has a built-in ngrok client. Instead of opening listening ports, it connects out to ngrok and receives traffic through ngrok tunnels: an HTTP tunnel on your ngrok domain for Devolutions Server or Devolutions Cloud, web sessions and recordings, and optionally a TCP tunnel for native Remote Desktop Manager sessions. Use it when you can't change the firewall of the Devolutions Gateway network, or to add the ngrok edge in front of an internal gateway. It works with Devolutions Server and Devolutions Cloud.

## Prerequisites

* An ngrok account with a domain for the HTTP tunnel and, for native sessions, a TCP address. TCP addresses require a paid ngrok plan.
* Your ngrok authentication token, from the ngrok dashboard.
* Outbound internet access from the Devolutions Gateway machine to ngrok.
* The provisioner public key of your Devolutions Server or Devolutions Cloud: in ***Administration*** – ***Devolutions Gateway***, click ***More*** – ***Download public key***. The file must be readable by the Devolutions Gateway service account (NETWORK SERVICE by default).

{% hint style="warning" %}
The ngrok authentication token is stored in clear text in `gateway.json`. Anyone who can read the configuration folder can use your ngrok account. Keep the default folder permissions.
{% endhint %}

## Set up ngrok

1. In the ngrok dashboard, reserve a domain for Devolutions Gateway, for example `gateway.contoso.com` or a domain provided by ngrok.
2. For native Remote Desktop Manager sessions, reserve a TCP address. Note the host and the port, for example `1.tcp.ngrok.io:21746`.
3. Copy your authentication token.

## Install Devolutions Gateway with ngrok (Windows)

1. Run the Devolutions Gateway installer and choose the destination folder.
2. In ***Configuration***, keep ***Now*** and select ***Enable access over the internet using ngrok***.
3. In the ***ngrok*** page ("Use ngrok for simplified remote access from the Internet. Gateway listeners allow access from any IP address by default."), enter:
   * ***Auth Token***: your ngrok authentication token.
   * ***Domain***: the ngrok domain for web client access.
   * ***Native Client Access***: set ***Configure*** to ***Now*** to add a TCP tunnel, then enter the ***Remote Address*** (the ngrok TCP address) in the `{host}:{port}` format. When ***Enable the Gateway web interface*** isn't selected, the TCP tunnel is always configured.
4. In ***Companion Server*** or ***Encryption Keys***, give the provisioner public key.
5. Review the ***Summary*** and install.

With ngrok, the installer:

* Configures no listener ports: all traffic comes through the ngrok tunnels.
* Sets `Hostname` to the ngrok domain.
* Configures no certificate: ngrok serves HTTPS for your domain.
* Allows connections from every address (`AllowCidrs` = `0.0.0.0/0`) on each tunnel.

Validation messages of the ***ngrok*** page: "The authentication token is required", "The domain is required and must be a valid hostname", "The remote address is required", "The remote address must be a valid host and port in the format {host}:{port}".

## Configure ngrok in gateway.json

On Linux, or to change an existing installation, add the `Ngrok` object to `gateway.json` and restart the service.

```json
"Ngrok": {
  "AuthToken": "<your ngrok authentication token>",
  "Tunnels": {
    "http-endpoint": {
      "Proto": "http",
      "Domain": "gateway.contoso.com",
      "AllowCidrs": [ "0.0.0.0/0" ]
    },
    "tcp-endpoint": {
      "Proto": "tcp",
      "RemoteAddr": "1.tcp.ngrok.io:21746",
      "AllowCidrs": [ "0.0.0.0/0" ]
    }
  }
}
```

<table><thead><tr><th width="260">SETTING</th><th>DESCRIPTION</th></tr></thead><tbody><tr><td><strong><code>AuthToken</code></strong></td><td>ngrok authentication token.</td></tr><tr><td><strong><code>HeartbeatInterval</code></strong></td><td>Seconds between heartbeats to ngrok.</td></tr><tr><td><strong><code>HeartbeatTolerance</code></strong></td><td>Seconds without a heartbeat answer before the ngrok session reconnects.</td></tr><tr><td><strong><code>Metadata</code></strong></td><td>Text returned by the ngrok API when listing the sessions of Devolutions Gateway.</td></tr><tr><td><strong><code>ServerAddr</code></strong></td><td>ngrok server URL. Set it only for a custom ingress URL.</td></tr><tr><td><strong><code>Tunnels</code></strong></td><td>Map of tunnels: the key is the tunnel name, the value is the tunnel settings below.</td></tr><tr><td><strong><code>Proto</code></strong></td><td><code>http</code> or <code>tcp</code>.</td></tr><tr><td><strong><code>AllowCidrs</code></strong></td><td>Only connections from these CIDR ranges are accepted. Set at least one range, or no outside connection is accepted. <code>0.0.0.0/0</code> accepts every IPv4 address.</td></tr><tr><td><strong><code>DenyCidrs</code></strong></td><td>Connections from these CIDR ranges are rejected.</td></tr><tr><td><strong><code>Metadata</code></strong> (tunnel)</td><td>Text shown in the ngrok API when listing tunnel sessions.</td></tr><tr><td><strong><code>Domain</code></strong> (<code>http</code>)</td><td>The domain registered in the ngrok dashboard.</td></tr><tr><td><strong><code>CircuitBreaker</code></strong> (<code>http</code>)</td><td>Ratio from 0 to 1. Requests are rejected when 5XX responses exceed this ratio.</td></tr><tr><td><strong><code>Compression</code></strong> (<code>http</code>)</td><td><code>true</code> to compress HTTP responses with gzip.</td></tr><tr><td><strong><code>RemoteAddr</code></strong> (<code>tcp</code>)</td><td>The TCP address and port registered in the ngrok dashboard.</td></tr></tbody></table>

To restrict who can reach the gateway, replace `0.0.0.0/0` with the public ranges of your users and of Devolutions Server or Devolutions Cloud.

With the PowerShell module, the same configuration is built with `New-DGatewayNgrokConfig`, `New-DGatewayNgrokTunnel` and `Set-DGatewayConfig -Ngrok`:

```powershell
$Ngrok = New-DGatewayNgrokConfig -AuthToken (Read-Host 'ngrok authentication token')
$Http = New-DGatewayNgrokTunnel -Http -Domain 'gateway.contoso.com' -AllowCidrs @('0.0.0.0/0')
$Tcp = New-DGatewayNgrokTunnel -Tcp -RemoteAddr '1.tcp.ngrok.io:21746' -AllowCidrs @('0.0.0.0/0')
$Ngrok.Tunnels = [PSCustomObject]@{ 'http-endpoint' = $Http; 'tcp-endpoint' = $Tcp }
Set-DGatewayConfig -Ngrok $Ngrok
Restart-DGateway
```

`Set-DGatewayConfig` removes the keys the module doesn't know from `gateway.json`. See [Manage Devolutions Gateway with PowerShell](https://docs.devolutions.net/gateway/for-administrators/powershell.md).

When Devolutions Gateway can't connect to ngrok, the log shows "couldn't create ngrok session".

## Register the gateway in Devolutions Server

1. In the Devolutions Server web interface, go to ***Administration*** – ***Devolutions Gateway***.
2. Click ***Add*** and select ***Gateway***.
3. Fill in:
   * ***Devolutions Gateway URL***: the ngrok domain with `https://`, for example `https://gateway.contoso.com`.
   * ***TCP Hostname*** and ***TCP Listening Port***: the host and the port of the ngrok TCP address, for example `1.tcp.ngrok.io` and `21746`.
4. Click ***Test connection*** to check that the domain is reachable. ***Auto-Detect*** doesn't work with ngrok: enter the TCP values by hand.
5. Click ***Save***.
6. In the menu of the gateway, run ***Publish Gateway configuration*** if it's offered, then ***Publish revocation list***.

## Register the gateway in Devolutions Cloud

1. In Devolutions Cloud, go to ***Administration*** – ***Devolutions Gateway***.
2. Click ***Add*** and select ***Gateway***.
3. Fill in ***Devolutions Gateway URL***, ***TCP Hostname*** and ***TCP Listening Port*** as for Devolutions Server, and use ***Test connection***.
4. In the ***Vaults***, ***Groups*** and ***Users*** tabs, choose who can use the gateway.
5. Click ***Add***.
6. In the menu of the gateway, select ***Publish Gateway configuration***.

## Next

* [Register and configure the gateway in Devolutions Server](https://docs.devolutions.net/gateway/guides/devolutions-server/register-and-configure.md)
* [Register and configure the gateway in Devolutions Cloud](https://docs.devolutions.net/gateway/guides/devolutions-cloud/register-and-configure.md)
* [Harden Devolutions Gateway](https://docs.devolutions.net/gateway/for-administrators/hardening.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.devolutions.net/gateway/guides/reverse-proxies/ngrok.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
