-
Notifications
You must be signed in to change notification settings - Fork 3
fix: bypass Squid for host.docker.internal MCP gateway traffic #543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
In chroot mode, the agent communicates with the MCP gateway via host.docker.internal. This traffic gets DNAT'd to Squid, where Squid fails with "Invalid URL - Missing hostname" because rmcp sends relative URLs (GET /path instead of GET http://host/path). When --enable-host-access is used, add iptables rules to let traffic to host.docker.internal bypass Squid entirely. This traffic is internal (agent → MCP gateway) and shouldn't be domain-filtered. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
Chroot tests failed Smoke Chroot failed - See logs for details. |
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
Deno Build Test Results
Overall: ✅ PASS All Deno tests completed successfully.
|
C++ Build Test Results
Overall: PASS ✅ All C++ projects built successfully.
|
Node.js Build Test Results
Overall: PASS ✅ All Node.js projects installed successfully and passed their test suites.
|
❌ Build Test: Java - FAILEDEnvironment Error: Maven installation is corrupted and cannot run. Error DetailsTest Results
Overall: FAILED The Maven binary at
|
Smoke Test ResultsLast 2 merged PRs:
Test Results:
Overall: PASS
|
Smoke Test Results (Copilot)Last 2 merged PRs:
Test Results:
Status: PASS cc: @Mossaka
|
Go Build Test Results
Overall: PASS ✅ All Go projects built and tested successfully.
|
There was a problem hiding this 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 a Squid proxy issue where MCP gateway traffic to host.docker.internal in chroot mode fails because rmcp sends relative URLs that Squid cannot handle. The solution adds an iptables bypass for host.docker.internal when --enable-host-access is enabled, allowing this internal agent-to-gateway traffic to skip Squid entirely.
Changes:
- Added
AWF_ENABLE_HOST_ACCESSenvironment variable to signal host access enablement to the agent container - Added comprehensive test coverage for the new environment variable (3 tests covering true/false/undefined states)
- Added iptables rules in
setup-iptables.shto bypass Squid forhost.docker.internaltraffic when host access is enabled
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/docker-manager.ts | Sets AWF_ENABLE_HOST_ACCESS='1' environment variable when enableHostAccess is true |
| src/docker-manager.test.ts | Adds 3 new tests to verify AWF_ENABLE_HOST_ACCESS is correctly set/unset based on enableHostAccess config |
| containers/agent/setup-iptables.sh | Adds iptables NAT RETURN and OUTPUT ACCEPT rules to bypass Squid for host.docker.internal traffic when AWF_ENABLE_HOST_ACCESS is set |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Enable host.docker.internal for agent when --enable-host-access is set | ||
| if (config.enableHostAccess) { | ||
| agentService.extra_hosts = ['host.docker.internal:host-gateway']; | ||
| environment.AWF_ENABLE_HOST_ACCESS = '1'; |
Copilot
AI
Feb 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value '1' is inconsistent with other boolean AWF environment variables in this codebase. AWF_CHROOT_ENABLED and AWF_SSL_BUMP_ENABLED both use 'true' as their value (see lines 393 and 488). While the current implementation works because setup-iptables.sh checks with [ -n "$AWF_ENABLE_HOST_ACCESS" ] (which accepts any non-empty value), using 'true' would be more consistent with established patterns and would prevent potential confusion if the checking logic changes in the future.
| environment.AWF_ENABLE_HOST_ACCESS = '1'; | |
| environment.AWF_ENABLE_HOST_ACCESS = 'true'; |
| if [ -n "$HOST_GATEWAY_IP" ]; then | ||
| echo "[iptables] Allow direct traffic to host gateway (${HOST_GATEWAY_IP}) - bypassing Squid..." | ||
| iptables -t nat -A OUTPUT -d "$HOST_GATEWAY_IP" -j RETURN | ||
| iptables -A OUTPUT -d "$HOST_GATEWAY_IP" -j ACCEPT |
Copilot
AI
Feb 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The OUTPUT filter chain rule (line 132) is placed in the middle of the NAT table configuration section, which makes the script structure harder to follow. According to the script's organization pattern (as documented by the "OUTPUT filter chain rules" comment at line 203), all filter chain rules should be grouped together after the NAT table rules are configured. While this works functionally (iptables evaluates NAT first, then filter), consider moving this ACCEPT rule to the OUTPUT filter chain section (after line 221) alongside the other filter rules for better code organization and maintainability.
Build Test: Bun - FAIL ❌Test Results
Overall: FAIL Error DetailsBoth projects failed with identical runtime errors: Root Cause: Bun 1.3.8 crashes in the container environment with segmentation faults. This appears to be an incompatibility between Bun and the container's kernel (6.11.0-1018-azure) or missing /proc/cpuinfo. Environment:
The test repository and test files are valid but Bun cannot execute in this environment.
|
Summary
host.docker.internal. This traffic gets DNAT'd to Squid, where Squid fails with "Invalid URL - Missing hostname" because rmcp sends relative URLs (GET /pathinstead ofGET http://host/path).--enable-host-accessis used, add iptables rules to let traffic tohost.docker.internalbypass Squid entirely. This traffic is internal (agent → MCP gateway) and shouldn't be domain-filtered.AWF_ENABLE_HOST_ACCESSenv var to signalsetup-iptables.shwhen host access is enabled.Test plan
npm run buildcompilesnpm test— 731 unit tests pass (including 3 new tests)npm run lint— no errorssudo awf --enable-host-access --allow-host-ports 8080 --allow-domains host.docker.internal --build-local --log-level debug -- curl -v http://host.docker.internal:8080/to confirm[iptables] Allow direct traffic to host gatewayappears in logs🤖 Generated with Claude Code