Configuração
Rode vários túneis a partir de um arquivo rl-tunnel.yml, defina opções com variáveis de ambiente e use tokens no CI.
1 min de leitura
Para um túnel, as flags bastam. Quando você trabalha com vários serviços, descreva todos uma vez em um arquivo rl-tunnel.yml na raiz do projeto.
O arquivo rl-tunnel.yml
# rl-tunnel.ymlversion: 1tunnels: web: proto: http port: 3000 subdomain: my-app # reserved in your dashboard api: proto: http port: 8080 subdomain: my-app-api auth: "admin:${API_PASSWORD}" # read from the environment, never commit the password allow_ip: ["203.0.113.0/24"] no_body: true db: proto: tcp port: 5432Campos de cada túnel
proto: http | tcp # requiredport: 3000 # requiredhost: 192.168.0.20 # optional, default localhostsubdomain: my-app # http only; must be reserved in your accountauth: "user:pass" # http only; ${VAR} is expanded from the environmentallow_ip: ["203.0.113.7"] # IPs or CIDRshost_header: app.local # http onlyno_body: true # don't capture bodies in the inspectorIniciando os túneis
# Start every tunnel in the filerl-tunnel start --all# Or only some of themrl-tunnel start web api# A file in another placerl-tunnel start --all --config ./infra/rl-tunnel.ymlCada linha do log recebe o nome do túnel como prefixo, como [web]. Se um túnel falhar de forma definitiva (por exemplo, um subdomínio que você não reservou), todos os túneis são encerrados e o erro diz qual falhou, para você nunca ficar com um conjunto pela metade. Quedas de rede passageiras são retentadas por túnel.
Variáveis de ambiente
export RL_TUNNEL_TOKEN=rlt_xxxxxxxxxxxx # access token (CI, servers)export RL_TUNNEL_NO_UPDATE_CHECK=1 # silence the new-version noticeexport RL_TUNNEL_HISTORY=/path/history # where inspect/replay keep requestsexport RL_TUNNEL_NO_HISTORY=1 # don't keep requests on diskexport NO_COLOR=1 # no colors in the terminalHeader Host
Alguns apps (multi-tenant, virtual hosts) dependem do header Host. Reescreva com --host-header ou host_header:
# Rewrite the Host header for apps that depend on it (vhosts, multi-tenant)rl-tunnel http 3000 --host-header app.localUsando no CI
Crie um token no painel e guarde como secret. Não é preciso login pelo navegador:
# .github/workflows/preview.yml- name: Open preview tunnel env: RL_TUNNEL_TOKEN: ${{ secrets.RL_TUNNEL_TOKEN }} run: | npm install -g resolvelabs-tunnel rl-tunnel http 3000 --no-body &