Run frontier MoE models on hardware you already own β pure C, zero deps, experts streamed from disk. Tiny engine, immense model. π¦
C
fix(server): let an operator reach a public bind β --allowed-host '*' (#990)
JustVugg02e5b0b17494
diff --git a/c/openai_server.py b/c/openai_server.pyindex 4e901768..68111a95 100644--- a/c/openai_server.py+++ b/c/openai_server.py@@ -2318,12 +2318,25 @@ class APIHandler(BaseHTTPRequestHandler):name = name.strip().lower()allowed = set(self.LOOPBACK_HOSTS)allowed.update(self.server.allowed_hosts) # #597: operator-trusted reverse-proxy names+ # A wildcard is an explicit operator opt-out of the guard, for the case+ # the guard cannot serve: a container/LAN bind reached by an IP or DNS+ # name the server cannot predict (#990 -- Docker port-map, the browser+ # sends the host's address, which the container never knows). The guard+ # protects a LOOPBACK bind from a malicious page; once bound to 0.0.0.0+ # the exposure is already chosen, so `*` adds no risk that bind did not.+ if "*" in allowed:+ returntry:allowed.add(str(self.server.server_address[0]).strip("[]").lower())except Exception:passif name not in allowed:- raise APIError(403, "Host header not allowed.", None, "forbidden")+ raise APIError(+ 403,+ "Host header %r not allowed. Add it with --allowed-host %s "+ "(or COLI_ALLOWED_HOSTS), or --allowed-host '*' to accept any "+ "host when the bind is already public." % (name or "(empty)", name or "<host>"),+ None, "forbidden")def read_json(self):try:@@ -3126,6 +3139,9 @@ def serve(model, host="127.0.0.1", port=8000, model_id="glm-5.2-colibri", api_keprint("refusing to bind %s beyond localhost without COLI_API_KEY set ""(set COLI_ALLOW_INSECURE_BIND=1 to override)" % host, file=sys.stderr)sys.exit(1)+ if allowed_hosts and "*" in allowed_hosts:+ print("WARNING: --allowed-host '*' accepts ANY Host header "+ "(DNS-rebinding guard disabled)", file=sys.stderr)origins = DEFAULT_CORS_ORIGINS if cors_origins is None else tuple(cors_origins)# Bind before starting the 744B engine. A stale/occupied port must fail in# milliseconds rather than loading hundreds of GB and leaking a child.diff --git a/c/tests/test_openai_server.py b/c/tests/test_openai_server.pyindex d9c02788..1b382f59 100644--- a/c/tests/test_openai_server.py+++ b/c/tests/test_openai_server.py@@ -1464,6 +1464,31 @@ class AllowedHostsTest(unittest.TestCase):server = self._make_server(allowed_hosts=("proxy.example.ts.net",))self.assertEqual(self._get_models(server.server_port, "evil.example.com"), 403)+ def test_wildcard_accepts_any_host(self):+ # #990: a Docker/LAN bind reached by an unpredictable IP. The wildcard is+ # an explicit operator opt-out, so ANY host passes -- but loopback and a+ # real name still work, i.e. it widens rather than replaces.+ server = self._make_server(allowed_hosts=("*",))+ port = server.server_port+ self.assertEqual(self._get_models(port, "10.20.30.40:36873"), 200)+ self.assertEqual(self._get_models(port, "colibri.example.com"), 200)+ self.assertEqual(self._get_models(port, "localhost"), 200)++ def test_rejection_message_names_the_host_and_the_fix(self):+ server = self._make_server()+ conn = http.client.HTTPConnection("127.0.0.1", server.server_port, timeout=2)+ try:+ conn.putrequest("GET", "/v1/models", skip_host=True)+ conn.putheader("Host", "myserver.lan:36873")+ conn.endheaders()+ resp = conn.getresponse()+ body = resp.read().decode()+ finally:+ conn.close()+ self.assertEqual(resp.status, 403)+ self.assertIn("myserver.lan", body) # the offending host, so the user can copy it+ self.assertIn("--allowed-host", body) # and how to fix it+class ThinkingSplitUnitTest(unittest.TestCase):"""#597 item 4: the GLM reasoning splitter, incl. mkelcb's cross-chunk cases."""diff --git a/docker/README.md b/docker/README.mdindex 7a57ab8a..adb3ccc6 100644--- a/docker/README.md+++ b/docker/README.md@@ -520,6 +520,24 @@ docker run --rm -p 5000:5000 -v /nvme/glm52_i4:/model colibri \serve --host 0.0.0.0 --model-id glm-5.2 --ram 24```+**Reaching it from another machine (or `coli web`).** Binding `--host 0.0.0.0`+is not enough: the server has a DNS-rebinding guard that only trusts the Host+header for loopback and its own bind address, so a browser pointed at+`http://<server-ip>:<port>` gets `403 Host header not allowed`. Behind Docker's+port mapping the container cannot know the address the browser will send, so+tell it what to accept β the exact name/IP, or `*` when the bind is already+deliberately public:++```bash+docker run --rm -p 36873:8000 -e COLI_ALLOW_INSECURE_BIND=1 \+ -v /nvme/glm52_i4:/model colibri \+ web --host 0.0.0.0 --allowed-host '*'+```++`--allowed-host '*'` disables the guard (it warns at startup); prefer an+explicit `--allowed-host my-server.lan` when you know the name. This is a+LAN-exposure decision, hence opt-in alongside `COLI_ALLOW_INSECURE_BIND=1`.+The entrypoint is `coli`, so the first argument is the subcommand (`info`,`chat`, `serve`, `run`, `plan`, `doctor`) β no `./coli` prefix. The containerruns as UID 1000, so the model directory must be readable by that user