Client

Tunnel Templates

Learn how to setup tunnel templates to reuse tunnel settings

Why Use Templates?

Templates provide several benefits:

  • Run multiple tunnels simultaneously
  • Reuse common configurations for frequently used subdomains and ports
  • Quick startup with simple commands
  • Consistent setups across different environments

Setting Up Templates

Open the config file

Open the portr client config file by running:

portr config edit

Configure templates

This will open a file with contents similar to:

server_url: example.com
ssh_url: example.com:2222
secret_key: { your-secret-key }
tunnels:
  - name: portr
    subdomain: portr
    port: 4321

Add more templates

You can create additional tunnel templates under the tunnels key:

tunnels:
  - name: portr
    subdomain: portr
    port: 4321
  - name: pg
    subdomain: postgres-dev
    port: 5432
    type: tcp
  - name: api
    subdomain: api-dev
    port: 3000
    type: http

Using Templates

Start individual tunnels

Start specific tunnels by name:

portr start portr

Start multiple tunnels

Start multiple services at once:

portr start portr pg api

Start all tunnels

Start all configured tunnels:

portr start

For more details about available commands and options, run portr --help.

Template Configuration Options

Each tunnel template supports the following options:

  • name: A unique identifier for the tunnel
  • subdomain: The subdomain to use for the tunnel
  • port: The local port to tunnel
  • type: The tunnel type (http, tcp, or websocket)

Example Configurations

Development Environment

tunnels:
  - name: frontend
    subdomain: app-dev
    port: 3000
    type: http
  - name: backend
    subdomain: api-dev
    port: 8000
    type: http
  - name: database
    subdomain: db-dev
    port: 5432
    type: tcp

Testing Environment

tunnels:
  - name: staging
    subdomain: staging
    port: 3000
    type: http
  - name: webhook-test
    subdomain: webhooks
    port: 4000
    type: http