Skip to content

fix: set NO_PROXY for host gateway to bypass Squid for MCP#554

Merged
Mossaka merged 1 commit intomainfrom
fix/no-proxy-for-host-gateway
Feb 6, 2026
Merged

fix: set NO_PROXY for host gateway to bypass Squid for MCP#554
Mossaka merged 1 commit intomainfrom
fix/no-proxy-for-host-gateway

Conversation

@Mossaka
Copy link
Collaborator

@Mossaka Mossaka commented Feb 6, 2026

Summary

  • Sets NO_PROXY / no_proxy env vars when --enable-host-access is enabled
  • Includes host.docker.internal, network gateway IP (172.30.0.1), Squid IP, and localhost
  • Prevents HTTP clients (like Codex's reqwest) from proxying MCP gateway traffic through Squid

Root Cause

v0.13.10 added iptables NAT bypass for 172.30.0.1, which prevents DNAT redirection. But the HTTP_PROXY env var still causes HTTP clients to send MCP traffic through Squid as a forward proxy. Concurrent MCP Streamable HTTP (SSE) connections through Squid's forward proxy trigger comm.cc:1583 assertion failure and Squid segfaults.

Evidence from smoke-codex CI (v0.13.10)

The iptables bypass IS working:

[iptables] Allow direct traffic to network gateway (172.30.0.1) - bypassing Squid...

But MCP connections still fail because reqwest uses HTTP_PROXY:

rmcp: sse client event stream terminated with error: hyper::Error(IncompleteMessage)
url: "http://172.30.0.1/mcp/safeoutputs"

Local Verification

With NO_PROXY set, curl confirms direct bypass:

* Uses proxy env variable no_proxy == 'localhost,127.0.0.1,172.30.0.10,host.docker.internal,172.30.0.1'
* Trying 172.30.0.1:80...
< HTTP/1.0 200 OK
< Server: BaseHTTP/0.6 Python/3.10.12

SSE streams work, concurrent SSE+POSTs complete, Squid stays alive.

Test plan

  • 732/732 unit tests pass locally
  • CI passes
  • Release v0.13.11, update gh-aw PR #14027, smoke-codex passes

🤖 Generated with Claude Code

The iptables NAT bypass from v0.13.10 prevents DNAT redirection,
but HTTP_PROXY env var still causes HTTP clients (like Codex's
reqwest) to send MCP traffic through Squid as a forward proxy.
Concurrent SSE connections through Squid crash it (comm.cc:1583).

Set NO_PROXY with host.docker.internal and the network gateway IP
when --enable-host-access is enabled, so MCP gateway traffic
bypasses both DNAT and the forward proxy.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 6, 2026 08:55
@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

💫 TO BE CONTINUED... Smoke Claude failed! Our hero faces unexpected challenges...

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 82.10% 82.16% 📈 +0.06%
Statements 82.14% 82.19% 📈 +0.05%
Functions 81.95% 81.95% ➡️ +0.00%
Branches 75.44% 75.48% 📈 +0.04%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/docker-manager.ts 83.0% → 83.2% (+0.25%) 82.3% → 82.5% (+0.26%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an issue where MCP (Model Context Protocol) traffic was being routed through Squid proxy despite iptables NAT bypass rules being in place. The root cause was that the HTTP_PROXY environment variable caused HTTP clients (like reqwest) to use Squid as a forward proxy, leading to Squid crashes when handling concurrent SSE (Server-Sent Events) connections from MCP.

Changes:

  • Adds NO_PROXY and no_proxy environment variables when --enable-host-access is enabled
  • Computes the network gateway IP (first usable IP in subnet) and includes it in the NO_PROXY list
  • Prevents HTTP clients from proxying MCP gateway traffic through Squid

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +338 to +345
if (config.enableHostAccess) {
// Compute the network gateway IP (first usable IP in the subnet)
const subnetBase = networkConfig.subnet.split('/')[0]; // e.g. "172.30.0.0"
const parts = subnetBase.split('.');
const networkGatewayIp = `${parts[0]}.${parts[1]}.${parts[2]}.1`;
environment.NO_PROXY = `localhost,127.0.0.1,${networkConfig.squidIp},host.docker.internal,${networkGatewayIp}`;
environment.no_proxy = environment.NO_PROXY;
}
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new NO_PROXY environment variable configuration lacks test coverage. Consider adding a test case in the 'enableHostAccess option' describe block in docker-manager.test.ts to verify that both NO_PROXY and no_proxy are set correctly when enableHostAccess is true, and that they include all the expected hosts (localhost, 127.0.0.1, squid IP, host.docker.internal, and the computed network gateway IP).

Copilot uses AI. Check for mistakes.
@Mossaka Mossaka merged commit 2bd65cc into main Feb 6, 2026
83 of 84 checks passed
@Mossaka Mossaka deleted the fix/no-proxy-for-host-gateway branch February 6, 2026 09:11
Mossaka added a commit to github/gh-aw that referenced this pull request Feb 6, 2026
Adds NO_PROXY for host gateway IPs to fully bypass Squid for MCP traffic.
See github/gh-aw-firewall#554 for details.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant