Skip to content

Protect an HTTP tunnel

Require a shared secret in the X-Tubu-Auth header before forwarding HTTP requests.

Run an HTTP service on port 3000. Use a client that can set custom request headers.

Set a secret

Save the example as tubu.yml and replace REPLACE_WITH_A_RANDOM_SECRET with a strong secret. Keep the file out of source control.

tunnels:
  - type: http
    domain: my-private-app.tubu.dev
    target: 3000
    secret: "REPLACE_WITH_A_RANDOM_SECRET"
npx tubu-cli --config tubu.yml

The API key still comes from TUBU_TOKEN. The HTTP secret is a separate credential that callers send in X-Tubu-Auth.

Verify access

curl -i https://my-private-app.tubu.dev

Expect 401 without the header. Use your configured secret in the next request:

curl --fail https://my-private-app.tubu.dev \
  -H 'X-Tubu-Auth: REPLACE_WITH_A_RANDOM_SECRET'

Expect your app response.

See secret configuration for inheritance, SHA-256 digests and validation rules.