Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
deploy: allow a TLS terminator on another host
David Neyra5741fe298473
diff --git a/.env.example b/.env.exampleindex 05344a88e3..50ea29b848 100644--- a/.env.example+++ b/.env.example@@ -8,8 +8,13 @@ OMB_PUBLIC_URL=OMB_WEBHOOK_PUBLIC_URL=# For Tailscale Serve, set the HTTPS hostname (without scheme or path).# Set OMB_PUBLIC_URL to https:// followed by the same hostname.-# Requires OMB_BIND_ADDRESS=127.0.0.1 and a trusted local HTTPS proxy.+# Requires OMB_BIND_ADDRESS=127.0.0.1 and a trusted local HTTPS proxy,+# or a bind address others can reach plus OMB_TRUSTED_PROXY_CIDRS.OMB_HTTPS_HOST=+# Name the peers that may claim the HTTPS hostname (CIDRs, space separated).+# Required when OMB_HTTPS_HOST is set with any bind address but 127.0.0.1.+# Empty keeps the default: only the host itself can reach a loopback bind.+OMB_TRUSTED_PROXY_CIDRS=OMB_BASE_IMAGE=ghcr.io/milind-soni/openmausbot:latestOMB_LOCAL_IMAGE=openmausbot-local:latestCADDY_IMAGE=caddy:2diff --git a/compose.yaml b/compose.yamlindex 4fa9e9555c..1fb4420579 100644--- a/compose.yaml+++ b/compose.yaml@@ -48,18 +48,20 @@ services:environment:OMB_HTTPS_HOST: ${OMB_HTTPS_HOST:-}OMB_BIND_ADDRESS: ${OMB_BIND_ADDRESS:-127.0.0.1}+ OMB_TRUSTED_PROXY_CIDRS: ${OMB_TRUSTED_PROXY_CIDRS:-}command:- /bin/sh- -ec- |- export OMB_UPSTREAM_SCHEME=http- if [ -n "$$OMB_HTTPS_HOST" ] && [ "$$OMB_BIND_ADDRESS" != "127.0.0.1" ]; then- echo "OMB_HTTPS_HOST requires OMB_BIND_ADDRESS=127.0.0.1; forward HTTPS through a trusted local proxy." >&2+ # HTTPS is claimed by the peer that terminates TLS, so a bind address+ # that others can reach has to name that peer.+ if [ -n "$$OMB_HTTPS_HOST" ] && [ "$$OMB_BIND_ADDRESS" != "127.0.0.1" ] && [ -z "$$OMB_TRUSTED_PROXY_CIDRS" ]; then+ echo "OMB_HTTPS_HOST with OMB_BIND_ADDRESS=$$OMB_BIND_ADDRESS requires OMB_TRUSTED_PROXY_CIDRS naming the TLS terminator; forward HTTPS through a trusted local proxy." >&2exit 1fi- if [ -n "$$OMB_HTTPS_HOST" ]; then- export OMB_UPSTREAM_SCHEME=https- fi+ # An empty list lets any peer claim the HTTPS hostname, which only the+ # loopback bind keeps to the host itself.+ export OMB_TRUSTED_PROXY_CIDRS="$${OMB_TRUSTED_PROXY_CIDRS:-0.0.0.0/0 ::/0}"exec caddy run --config /etc/caddy/Caddyfile --adapter caddyfile# Started with the server, not after it is healthy: Caddy reaches it over the socket# whenever it answers, so `up` never waits on the server's health, and HTTPS is backdiff --git a/deploy/local/Caddyfile b/deploy/local/Caddyfileindex eac031f83f..9f615b75a4 100644--- a/deploy/local/Caddyfile+++ b/deploy/local/Caddyfile@@ -1,15 +1,25 @@:80 {- map {host} {upstream_scheme} {- {$OMB_HTTPS_HOST:https-disabled.invalid} {$OMB_UPSTREAM_SCHEME:http}- default http- }encode zstd gziphandle /hooks/* {reverse_proxy unix//run/openmausbot/hooks.sock}+ # HTTPS is claimed by the peer that terminates TLS: the ranges named in+ # OMB_TRUSTED_PROXY_CIDRS may present the HTTPS hostname, anyone else is+ # plain HTTP.+ @trusted_https {+ host {$OMB_HTTPS_HOST:https-disabled.invalid}+ remote_ip {$OMB_TRUSTED_PROXY_CIDRS}+ }+ handle @trusted_https {+ reverse_proxy unix//run/openmausbot/http.sock {+ header_up X-Forwarded-Proto https+ header_up -Accept-Encoding+ flush_interval -1+ }+ }handle {reverse_proxy unix//run/openmausbot/http.sock {- header_up X-Forwarded-Proto {upstream_scheme}+ header_up X-Forwarded-Proto httpheader_up -Accept-Encodingflush_interval -1}diff --git a/deploy/local/README.md b/deploy/local/README.mdindex d5e7e6382f..a7312bbde3 100644--- a/deploy/local/README.md+++ b/deploy/local/README.md@@ -27,6 +27,25 @@ Private tailnet webhook URLs are only reachable by callers on that tailnet.Without `OMB_HTTPS_HOST`, the bind address can be changed for HTTP access.Only use HTTPS hostname mapping with a trusted local TLS-terminating proxy.+The TLS terminator does not have to sit on the same host. When the containers+run on one machine and the terminator on another (a Cloudflare Tunnel on+another machine of the same network, for instance), name the terminator in+`OMB_TRUSTED_PROXY_CIDRS` and bind the port where the terminator can reach+it:++```sh+OMB_BIND_ADDRESS=192.168.1.20 OMB_HTTPS_HOST=omb.example.com \+OMB_TRUSTED_PROXY_CIDRS=192.168.1.50/32 docker compose up -d+```++`OMB_TRUSTED_PROXY_CIDRS` lists the addresses of the peers that may claim the+HTTPS hostname, as Caddy sees them. Only those peers are treated as+HTTPS; every other caller on the network stays plain HTTP even when it sends+that hostname. Caddy refuses to start when `OMB_HTTPS_HOST` is set with a+bind address other than `127.0.0.1` and no such list, so a reachable bind+address always names the terminator. Leave the list empty with the default+loopback bind, where the host itself is the only peer.+Sign in and pair:```sh