-
Notifications
You must be signed in to change notification settings - Fork 34
fix: rewrite localhost URLs to host.docker.internal when firewall is enabled #9281
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
…enabled When an agent runs inside a firewall container (Docker), localhost refers to the container itself, not the host machine. This causes HTTP MCP servers started on the host (like gh-aw mcp-server on port 8765) to be inaccessible. This fix: - Adds RewriteLocalhostToDocker flag to MCPConfigRenderer - Adds rewriteLocalhostToDockerHost() helper function - Updates all engine implementations to pass workflowData context - Rewrites localhost/127.0.0.1 URLs to host.docker.internal when firewall is enabled - Preserves localhost URLs when firewall is disabled (sandbox.agent.disabled: true) Fixes the Daily Firewall Report workflow which was failing because the agent couldn't access the gh-aw MCP server running on localhost:8765. Co-authored-by: Mossaka <[email protected]>
Addresses code review feedback: - Use table-driven approach with prefix matching for all protocols - Handle http/https for both localhost and 127.0.0.1 - Use HasPrefix for all checks to avoid matching URLs with localhost in path Co-authored-by: Mossaka <[email protected]>
|
🤖 DIAGNOSTIC COMPLETE: Smoke Copilot No Firewall STATUS: ALL_UNITS_OPERATIONAL. MISSION_SUCCESS. |
|
🎉 Yo ho ho! Smoke Copilot Safe Inputs found the treasure and completed successfully! ⚓💰 |
|
🎉 Yo ho ho! Changeset Generator found the treasure and completed successfully! ⚓💰 |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
|
📰 VERDICT: Smoke Copilot Playwright has concluded. All systems operational. This is a developing story. 🎤 |
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
|
✅ Firewall validation complete... Smoke Codex Firewall confirmed network sandboxing is operational. 🛡️ |
Smoke Test Results: Copilot Safe Inputs✅ File Writing: Test file created successfully Overall Status: The
|
Smoke Test Results: Copilot Engine (No Firewall)✅ PR Review: Last 2 merged PRs reviewed ( All tests passed successfully.
|
🧪 Copilot Smoke Test ResultsLast 2 merged PRs:
✅ File Writing: Created Overall: PASS ✅ cc @Mossaka
|
Smoke Test Results❌ Playwright MCP: Not available in environment Overall Status: ❌ FAIL
|
|
Smoke test results:
|
Smoke Test Results - Claude EngineRecent PRs:
Test Results:
Overall Status: PARTIAL PASS (5/6 tests passed)
|
|
PRs (merged): docs: document default mounted volumes for AWF sandbox; Enable CodeQL analysis for GitHub Actions workflows
|
HTTP MCP servers configured with
localhostURLs are inaccessible from inside firewall containers becauselocalhostresolves to the container, not the host machine. The Daily Firewall Report workflow failed because the agent couldn't reach thegh-awMCP server running onlocalhost:8765.Changes
rewriteLocalhostToDockerHost()that rewriteslocalhost/127.0.0.1URLs tohost.docker.internalwhen firewall is enabled (sandbox agent not disabled)RewriteLocalhostToDockerflag: Added toMCPConfigRendererstruct to control URL rewriting behaviorExample
Before (fails inside container):
After (works inside container):
The rewriting only applies when firewall is enabled. Setting
sandbox.agent.disabled: truepreserves localhost URLs.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/user/usr/bin/gh gh api user --jq .login /home/REDACTED/work/gh-aw/gh-aw/.github/workflows rev-parse /usr/bin/git xterm-color gh 0/x64/bin/node git -C /home/REDACTED/work/gh-aw/gh-aw/.github/workflows rev-parse(http block)/usr/bin/gh gh api user --jq .login /ref/tags/v8 sh /usr/bin/git 6642601/run-1007infocmp infocmp 64/bin/go git -C etup-go/git/ref/tags/v6 rev-parse /usr/bin/gh ithub-script/gitgh e/git 64/pkg/tool/linu/repos/actions/github-script/git/ref/tags/v8 gh(http block)/usr/bin/gh gh api user --jq .login runs/20260107-235213-35920/test-933456102/.github/workflows y /usr/bin/git 6675173/run-1019/tmp/gh-aw-compile-integration-579503576/gh-aw --jq 64/pkg/tool/linuadd git -C 3aee6377818e0f17--verbose rev-parse le-integration-2REDACTED /repos/actions/grm --jq ache/node/24.12./tmp/runc-shim-error.log le-integration-253570785/gh-aw(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Changeset
host.docker.internalwhen firewall is enabled; addRewriteLocalhostToDockerflag and propagate sandbox configuration to MCP renderers. Rewriting is skipped whensandbox.agent.disabled: true.