No description
  • Rust 72.5%
  • JavaScript 15.7%
  • HTML 6.6%
  • CSS 4.5%
  • Makefile 0.5%
  • Other 0.2%
Find a file
2026-04-26 17:34:40 +00:00
.forgejo/workflows fix(ci): replace build-linux.yaml with canonical release.yaml (#27) 2026-04-25 20:12:10 -04:00
crates feat(proxy): fall back to TCP peer addr in extract_client_ip 2026-04-26 20:24:31 +03:00
docs docs: update README and add documentation 2026-04-08 10:23:54 +02:00
patches/rustls-acme-0.15.1 refactor: simplify socket discovery and fix RPC base path for UI 2026-04-08 12:28:48 +02:00
.env.example add tls support 2026-02-18 08:07:07 +01:00
.gitignore Initial hero_proxy: reverse proxy for hero services 2026-02-16 00:34:57 +01:00
buildenv.sh chore: bump buildenv version to 0.5.0 2026-04-09 14:43:35 +02:00
Cargo.lock feat(proxy): tunnel WebSocket upgrades through path-prefix forwarder 2026-04-26 18:02:10 +03:00
Cargo.toml feat: sessions 17-18 — native dioxus islands, new URL routing, OSIS auth fix, build safety 2026-04-12 09:58:06 -04:00
Makefile fix(ci): restore Makefile so build.yaml workflow's make calls work (#26) 2026-04-25 19:56:41 -04:00
README.md refactor: update proxy architecture, remove legacy build scripts, and enhance OpenRPC schema 2026-04-19 15:37:51 +02:00

Hero Proxy

HTTP/HTTPS reverse proxy and service discovery for the Hero ecosystem. Routes incoming traffic to Hero services via URL-prefix → Unix domain socket forwarding, with TLS termination (self-signed or Let's Encrypt), SSH tunnels, OAuth, and a full management API.

Architecture

Internet / Browser
       │
  :80 (HTTP) / :443 (HTTPS)
       │
  hero_proxy_server
    ├── {domain}/* → ~/hero/var/sockets/{service}/*.sock
    ├── TLS (self-signed or Let's Encrypt / ACME)
    ├── SSH reverse-port tunnels
    ├── OAuth2 / bearer / signature auth per route
    └── OpenRPC JSON-RPC 2.0 management API
              │
       ~/hero/var/sockets/hero_proxy/rpc.sock

Crates

Crate Type Description
hero_proxy binary CLI — registers and starts/stops all services via hero_proc
hero_proxy_server binary TCP proxy + service discovery + OpenRPC API
hero_proxy_ui binary Admin dashboard
hero_proxy_sdk library Auto-generated typed client
weblib library Reusable web / TLS / ACME library

Sockets

All sockets under $HERO_SOCKET_DIR/hero_proxy/ (default ~/hero/var/sockets/hero_proxy/).

Socket Protocol Description
rpc.sock OpenRPC / JSON-RPC 2.0 Management API
ui.sock HTTP Admin dashboard

Ports (TCP)

Port Protocol Description
9997 HTTP Proxy ingress (dev / LAN)
9996 HTTPS Proxy ingress (TLS)
443 HTTPS Production ingress (Let's Encrypt)
80 HTTP Redirect → HTTPS (Let's Encrypt mode)

Service Management (Nushell)

All service lifecycle operations are done through Nushell using the service_proxy and proxy modules from hero_skills.

use services/service_proxy.nu *
use clients/proxy.nu *

Install and start

# Build release binaries, install to ~/hero/bin, register with hero_proc, start
service_proxy install
service_proxy start

Stop / restart

service_proxy stop
service_proxy restart   # stop → rebuild → start

Status and logs

service_proxy status    # hero_proc list for hero_proxy_*
service_proxy logs      # streaming logs from hero_proxy_server
service_proxy logs-ui   # streaming logs from hero_proxy_ui

Dev build (faster iteration)

service_proxy start --dev   # cargo build (debug), install, start

TLS / ACME Configuration

TLS settings are persisted in the database so they survive restarts without environment variables. DB values always take precedence over env vars.

# Set the domain for Let's Encrypt (required)
proxy system config set --dns-name proxy.example.com

# Set contact email (strongly recommended — expiry notifications)
proxy system config set --acme-email admin@example.com

# Switch to production CA (default is staging — safe to test first)
proxy system config set --acme-production true

# View current effective config and where each value comes from
proxy system config get

# Clear a field (reverts to env var fallback, or unset)
proxy system config remove dns_name

Response from proxy system config get

{
  dns_name:               "proxy.example.com"
  acme_email:             "admin@example.com"
  acme_production:        true
  dns_name_source:        "db"     # db | env | unset
  acme_email_source:      "db"     # db | env | unset
  acme_production_source: "db"     # db | env | default
}

Env var fallbacks (legacy / alternative)

DB key (via API) Environment variable Default
acme_dns_name HERO_PROXY_DNS_NAME — (self-signed)
acme_email HERO_PROXY_ACME_EMAIL — (no email)
acme_production HERO_PROXY_ACME_PRODUCTION false (staging)

Changes take effect the next time a listener with tls_mode=letsencrypt is started. Running listeners are not hot-reloaded — restart the listener after changing config.


Quick-start: public HTTPS with Let's Encrypt

# 1. Install and start the service
service_proxy install
service_proxy start

# 2. Configure ACME (while service is running — no restart needed for config)
proxy system config set --dns-name proxy.example.com --acme-email admin@example.com
proxy system config set --acme-production true

# 3. Add an HTTPS listener (starts the ACME challenge immediately)
proxy listener add "0.0.0.0:443" --protocol https --tls-mode letsencrypt

# 4. Verify
proxy listener status
proxy tls check proxy.example.com

Quick-start: SSH tunnel to a public server

# Create HTTP + HTTPS + DNS-bridge tunnels in one call and start them
proxy tunnel quick_add edge.example.com admin --auth-key-path ~/.ssh/id_ed25519

# Check status
proxy tunnel status
proxy tunnel check_dns 3

Domain routing

# Route a hostname to a local service socket
proxy domain add app.example.com socket /run/myapp.sock

# Route with bearer-token auth
proxy domain add api.example.com https https://127.0.0.1:9000 --auth-mode bearer

# Route with OAuth (Google)
proxy oauth set google google $CLIENT_ID $CLIENT_SECRET \
    --scopes "openid email profile"
proxy domain add dash.example.com http http://127.0.0.1:8080 \
    --auth-mode oauth --oauth-provider google

# List / inspect routes
proxy domain list
proxy domain get 3

Development

# Fast check without producing a binary
cargo check -p hero_proxy_server

# Run tests
cargo test

# Clippy
cargo clippy --all-targets -- -D warnings

# Format
cargo fmt

Documentation

The Nushell client reference lives in hero_skills:

  • tools/modules/clients/proxy.nu — all RPC commands
  • tools/docs/proxy.md — full command reference