Configuración
Ejecuta varios túneles desde un archivo rl-tunnel.yml, define opciones con variables de entorno y usa tokens en CI.
1 min de lectura
Para un túnel bastan las flags. Cuando trabajas con varios servicios, descríbelos una vez en un archivo rl-tunnel.yml en la raíz del proyecto.
El archivo 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 inspectorIniciar los túneles
# 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 línea del log lleva el nombre del túnel como prefijo, como [web]. Si un túnel falla de forma definitiva (por ejemplo, un subdominio que no reservaste), se detienen todos los túneles y el error indica cuál falló, para que nunca te quedes con un conjunto a medias. Las caídas de red pasajeras se reintentan por túnel.
Variables de entorno
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
Algunas apps (multi-tenant, virtual hosts) dependen del header Host. Reescríbelo con --host-header o host_header:
# Rewrite the Host header for apps that depend on it (vhosts, multi-tenant)rl-tunnel http 3000 --host-header app.localUsarlo en CI
Crea un token en tu panel y guárdalo como secret. No hace falta iniciar sesión en el 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 &