Skip to content

An ollamaProxy endpoint on its daemon's port passes validation, then every request returns 502 #14907

Backlog

Description

@shaojunying

Investigation Summary

  • OllamaProxy::validate_definition in crates/nemoclaw-sdk/src/services/installers/ollama/mod.rs (line 124 at fa6f2638c) only compares the two URL strings: self.endpoint != self.upstream.endpoint. A proxy endpoint http://172.20.0.1:11434/v1 in front of a daemon at http://127.0.0.1:11434/v1 passes.
  • The proxy container uses the host network ("network_mode":"host" in crates/nemoclaw-sdk/src/docker_compute.rs) and reads /proc/net/tcp.
  • Proxy::start in crates/nemoclaw-ollama-proxy/src/lib.rs checks the daemon before it binds, so startup succeeds. dispatch checks again before each request. loopback_listener then finds the proxy's own 172.20.0.1:11434 listener and returns "external Ollama must listen only on loopback". dispatch maps that to 502.
  • only_loopback_listeners_on_the_daemon_port_are_accepted in crates/nemoclaw-ollama-proxy/src/tests.rs shows that a non-loopback listener on the daemon's port fails the check.

Description

An ollamaProxy service whose endpoint uses the daemon's port on a private address passes validation and starts. Then every /v1/models and /v1/chat/completions request returns 502, because the proxy's daemon check counts its own listener. The 502 does not say why.
The documented example uses 11435 for the proxy and 11434 for the daemon, but nothing requires different ports.
I did not run a live daemon; the parse result is observed, and the runtime path is read from the code.

Expected: validation rejects a proxy endpoint on the daemon's port, with a message that names the port.

Reproduction Steps

At fa6f2638c, add this test to crates/nemoclaw-sdk/tests/ollama_proxy.rs:

#[test]
fn same_port() {
    let mut value = input();
    value["spec"]["services"]["ollama-auth"]["endpoint"] = json!("http://172.20.0.1:11434/v1");
    assert!(Document::parse(value.to_string().as_bytes()).is_err());
}

cargo test -p nemoclaw-sdk --test integration same_port fails: the document parses.

Environment

Ubuntu on WSL2, Rust 1.100.0, v1 at fa6f2638c.

Fix idea

Require the proxy endpoint's port to differ from the upstream port in validate_definition, with its own message. This keeps the per-request listener check strict. Excluding the proxy's own address from loopback_listener would also work, but it changes a security check to handle a configuration that has no use. PR: #14909

AI disclosure: I used Claude Code to find, reproduce, and fix this.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions