KinoReverseProxy (kino_reverse_proxy v0.1.0)

A module for creating reverse proxies for Kino applications in Livebook.

KinoReverseProxy allows Livebook apps to be accessed on their own domains. It is deployed as a Livebook app, listens for web traffic on an arbitrary port, and provides host-based routing to other deployed Livebook apps using either their Kino.Proxy URL or their port for standalone server processes.

Summary

Functions

Creates and starts a reverse proxy server for a single Kino application.

Creates and starts a reverse proxy server with host-based routing to multiple Kino applications.

Functions

proxy(url, options \\ [])

Creates and starts a reverse proxy server for a single Kino application.

Parameters

  • url - The URL of the Kino application to proxy
  • options - Additional options for the proxy server:
    • :port - The port to listen on (default: 5555)
    • :timeout - The timeout in milliseconds (default: 36000)
    • :scheme - The HTTP scheme to use (default: :http)

Examples

# Basic usage
KinoReverseProxy.proxy("https://speedrun.dev/proxy/apps/time-guesser")

# With custom port
KinoReverseProxy.proxy("https://speedrun.dev/proxy/apps/time-guesser", port: 8080)

proxy_hosts(hosts_map, options \\ [])

Creates and starts a reverse proxy server with host-based routing to multiple Kino applications.

Parameters

  • hosts_map - A map of hostnames to URLs, where each key is a hostname and each value is the URL to proxy for that host
  • options - Additional options for the proxy server:
    • :port - The port to listen on (default: 5555)
    • :timeout - The timeout in milliseconds (default: 36000)
    • :scheme - The HTTP scheme to use (default: :http)
    • :default_url - An optional default URL to route to when the host doesn't match any in the hosts_map

Examples

# Basic host-based routing
KinoReverseProxy.proxy_hosts(%{
  "app1.example.com" => "https://speedrun.dev/proxy/apps/time-guesser",
  "app2.example.com" => "https://speedrun.dev/proxy/apps/different-app"
})

# With custom port and default URL
KinoReverseProxy.proxy_hosts(
  %{
    "app1.example.com" => "https://speedrun.dev/proxy/apps/time-guesser",
    "app2.example.com" => "https://speedrun.dev/proxy/apps/different-app"
  },
  port: 8080,
  default_url: "https://speedrun.dev/proxy/apps/default-app"
)