Skip to content

Cloudflare Tunnel

Give your local engine a public HTTPS URL that you can save in TomoriBot. Run the engine and cloudflared on your PC; the hosted bot connects directly through the tunnel.

Cloudflare Tunnel is available on the Free plan. You need a domain active on Cloudflare; domain registration and your engine’s upstream service may have separate costs.

Start your engine using its setup guide and keep it bound to 127.0.0.1. Install cloudflared on that same computer:

Terminal window
winget show --id Cloudflare.cloudflared --exact
winget install --id Cloudflare.cloudflared --exact
cloudflared --version

Choose a hostname under your Cloudflare domain, such as engine.example.com. Replace it throughout this guide with your own hostname.

Terminal window
cloudflared tunnel login
cloudflared tunnel create home-engine

The first command opens a browser to authorize your domain. The second prints a tunnel UUID and creates its credential JSON. Keep that file and the account certificate private.

Create config.yml in your .cloudflared folder:

OSFolderCredential-file example
Windows%USERPROFILE%\.cloudflaredC:\Users\LOCAL_ACCOUNT\.cloudflared\TUNNEL_UUID.json
Linux~/.cloudflared/home/LOCAL_ACCOUNT/.cloudflared/TUNNEL_UUID.json
macOS~/.cloudflared/Users/LOCAL_ACCOUNT/.cloudflared/TUNNEL_UUID.json

Paste this example for CLIProxyAPI. Replace the UUID, absolute JSON path, and hostname. Keep single quotes around the credential path so Windows backslashes remain literal.

config.yml
tunnel: TUNNEL_UUID
credentials-file: 'ABSOLUTE_PATH_TO_TUNNEL_JSON'
ingress:
- hostname: engine.example.com
path: ^/v1/(models|chat/completions)$
service: http://127.0.0.1:8317
- service: http_status:404

For another engine, replace only path and service using the matching tab. The path rule exposes TomoriBot’s API routes; unmatched paths return 404.

path: ^/v1/(models|chat/completions)$
service: http://127.0.0.1:8317

Use your actual port: CLIProxyAPI defaults to 8317, ChatMock to 8000, and KoboldCPP to 5001. This profile also supports other OpenAI-compatible text engines. It excludes management APIs and model-unload operations.

To expose several engines, add a hostname rule for each before the final 404 rule. Give each its own hostname and loopback port. One tunnel can serve them all.

Open a terminal in the folder containing config.yml and validate it:

Terminal window
cloudflared tunnel --config ./config.yml ingress validate

Then publish DNS and run the tunnel:

Terminal window
cloudflared tunnel route dns home-engine engine.example.com
cloudflared tunnel --config ./config.yml run home-engine

For several hostnames, run route dns once per hostname. Leave the engine and connector running; no router port forwarding or inbound firewall exception is needed. After testing, use Cloudflare’s service instructions for automatic startup, with explicit config and credential paths for the service account.

Open /providers to share the connection in that server, or /personal providers to use your own connection:

EngineAPI compatibilityEndpoint URL
CLIProxyAPI, ChatMock, KoboldCPP, other text enginesOpenAI-Compatiblehttps://engine.example.com/v1
ComfyUIComfyUIhttps://engine.example.com
Local TTS wrapperstts-clonehttps://engine.example.com

Use your engine’s client key as the auth token if it enforces one; otherwise leave the field blank. CLIProxyAPI uses the key under access.api-keys. KoboldCPP’s text API uses its configured password. An arbitrary token entered only in TomoriBot does not enable authentication on the engine.

Add a model under the saved connection, select it for the matching capability, and test a small request. For ComfyUI, also test reference uploads, output downloads, and cancellation. For TTS, confirm playable audio. Keep management features disabled on the engine.

If the engine enforces authentication, confirm protected requests reject missing or incorrect keys. If it has no authentication, read the remaining exposure under Known risks below. Access and Caddy provide optional additional protection.

SymptomCheck
502Engine running, correct loopback port, connector on the same PC
1033 or disconnected tunnelConnector process, outbound port 7844, network connection, and computer sleep
401Engine’s client key or password matches TomoriBot’s auth token
403 or HTML login pageAn existing Access application can block direct API calls; see the optional Access setup if you use it
404Correct engine profile and URL; use exactly one /v1 for text
Stream cutoff or 524Engine/upstream health, computer sleep, and Cloudflare timeouts
Large uploads failCloudflare upload limits and the bot/engine limits; base64 increases payload size

Return generated media as bytes through the API. The hosted bot cannot read your PC’s local file paths or loopback download URLs. Production endpoints require public HTTPS and public DNS answers; keep TLS verification and SSRF checks enabled.

TomoriBot already mitigates the following risks when you use its provider panels:

RiskExisting mitigation
Ordinary members read a saved endpoint in the panelPanels are ephemeral. Server provider settings require Manage Server; personal settings load the invoking user’s own configuration.
A provider error exposes its URL or key in chatPublic errors use localized descriptions. Raw text error details are gated to server managers for server credentials, or the owner for personal credentials. Media tool failures return classified messages.
ComfyUI output links reveal the engine URLTomoriBot downloads the output and uploads it to Discord.
Opening a port exposes the PC directlyThe engine stays on loopback and cloudflared connects outbound; no public inbound engine port is needed.