Skip to content

Proxy to an intranet service

Forward requests from a public HTTPS URL to a service on your intranet.

Run the publisher on a machine that can reach the service

The Tubu publisher can run on a separate machine. It resolves the internal hostname and connects to the service from its own network. For this example, the publisher machine must be able to resolve api.internal and reach it on port 8080.

Publish the intranet URL

npx tubu-cli http http://api.internal:8080 --domain my-api.tubu.dev --authtoken YOUR_API_KEY

Requests to https://my-api.tubu.dev reach http://api.internal:8080 through the publisher.

Configure a reverse proxy in tubu.yml

One configuration can serve several intranet services. Use HTTP routes to send requests to different services on the same public domain. In this example, /api goes to the API and other paths go to the web frontend. PostgreSQL and Redis use their own TCP tunnels because their clients connect to a host and port.

Save as tubu.yml:

version: 1
tunnels:
  - type: http
    domain: my-web.tubu.dev
    target: http://web.internal:3000
    routes:
      - path: /api
        target: http://api.internal:8080
  - type: tcp
    domain: my-postgres.tubu.dev
    target: tcp://postgres.internal:5432
  - type: tcp
    domain: my-redis.tubu.dev
    target: tcp://redis.internal:6379

On the publisher machine that can reach all four intranet services, start the tunnels and keep them running.

npx tubu-cli --config tubu.yml --authtoken <apikey>

Visit https://my-web.tubu.dev for the frontend or https://my-web.tubu.dev/api for the API.

On the caller machine, start forward for PostgreSQL and keep it running.

npx tubu-cli forward 15432 -d my-postgres.tubu.dev

On the caller machine, start forward for Redis in a separate terminal and keep it running.

npx tubu-cli forward 16379 -d my-redis.tubu.dev

From another terminal on the same caller machine, connect your PostgreSQL client to 127.0.0.1:15432 or your Redis client to 127.0.0.1:16379.