Skip to content

fix(firewall): add api-proxy to allowed domains when enabled#804

Merged
lpcox merged 2 commits intoclaude/fix-github-actions-workflow-againfrom
claude/fix-github-actions-workflow-another-one
Feb 13, 2026
Merged

fix(firewall): add api-proxy to allowed domains when enabled#804
lpcox merged 2 commits intoclaude/fix-github-actions-workflow-againfrom
claude/fix-github-actions-workflow-another-one

Conversation

@Claude
Copy link
Contributor

@Claude Claude AI commented Feb 13, 2026

The agent container was unable to communicate with the api-proxy sidecar because the api-proxy hostname was not in Squid's allowed domains list, causing all HTTP requests to http://api-proxy:10000 and http://api-proxy:10001 to be blocked.

Changes

  • Domain whitelisting: Automatically include api-proxy in Squid's allowed domains when enableApiProxy is true
  • Tests: Added coverage for api-proxy domain inclusion/exclusion based on configuration

Implementation

// src/docker-manager.ts
const domainsForSquid = config.enableApiProxy && networkConfig.proxyIp
  ? [...config.allowedDomains, 'api-proxy']
  : config.allowedDomains;

const squidConfig = generateSquidConfig({
  domains: domainsForSquid,
  // ...
});

The fix ensures agent-to-proxy communication works when API proxy sidecar is deployed with OpenAI or Anthropic API keys.

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
@Claude Claude AI changed the title [WIP] Fix failing GitHub Actions workflow agent fix(firewall): add api-proxy to allowed domains when enabled Feb 13, 2026
@Claude Claude AI requested a review from lpcox February 13, 2026 05:08
@lpcox lpcox marked this pull request as ready for review February 13, 2026 05:08
Copilot AI review requested due to automatic review settings February 13, 2026 05:08
@lpcox lpcox merged commit 074d609 into claude/fix-github-actions-workflow-again Feb 13, 2026
2 checks passed
@lpcox lpcox deleted the claude/fix-github-actions-workflow-another-one branch February 13, 2026 05:08
Copy link
Contributor

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

Fixes Squid domain allowlisting so the agent can reach the api-proxy sidecar hostname when API proxying is enabled, preventing Squid from blocking requests to http://api-proxy:10000 / :10001.

Changes:

  • Add api-proxy to the Squid allowed domains list when enableApiProxy is enabled.
  • Add unit tests intended to verify inclusion/exclusion of api-proxy in the generated squid.conf.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/docker-manager.ts Extends the allowed domain list passed to generateSquidConfig to include api-proxy when API proxying is enabled.
src/docker-manager.test.ts Adds tests to validate that api-proxy is present/absent in squid.conf depending on enableApiProxy.
Comments suppressed due to low confidence (1)

src/docker-manager.test.ts:1906

  • Same issue as the prior test: errors from writeConfigs are ignored and the assertion is conditional on squid.conf existing, so the test may pass even when the config wasn’t generated. Prefer asserting the file was written (or mocking prerequisites) and then checking that api-proxy is absent when enableApiProxy is false.
      try {
        await writeConfigs(config);
      } catch {
        // May fail after writing configs
      }

      // Verify squid.conf does not include api-proxy when disabled
      const squidConfPath = path.join(testDir, 'squid.conf');
      if (fs.existsSync(squidConfPath)) {
        const content = fs.readFileSync(squidConfPath, 'utf-8');
        expect(content).toContain('github.com');
        expect(content).not.toContain('api-proxy');
      }

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

Comment on lines +1115 to +1117
// When API proxy is enabled, add api-proxy to allowed domains so agent can communicate with it
const domainsForSquid = config.enableApiProxy && networkConfig.proxyIp
? [...config.allowedDomains, 'api-proxy']
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

domainsForSquid appends 'api-proxy' unconditionally when enabled, which can create duplicate entries if the user already included api-proxy (or .api-proxy) in allowedDomains. Consider de-duping (e.g., via a Set or an includes check) before passing the list into generateSquidConfig to avoid redundant ACL lines.

Suggested change
// When API proxy is enabled, add api-proxy to allowed domains so agent can communicate with it
const domainsForSquid = config.enableApiProxy && networkConfig.proxyIp
? [...config.allowedDomains, 'api-proxy']
// Note: Use container path for SSL database since it's mounted at /var/spool/squid_ssl_db
// When API proxy is enabled, add api-proxy to allowed domains so agent can communicate with it,
// but avoid duplicating entries if the user already specified api-proxy (or .api-proxy).
const hasApiProxyDomain =
config.allowedDomains.includes('api-proxy') ||
config.allowedDomains.includes('.api-proxy');
const domainsForSquid = config.enableApiProxy && networkConfig.proxyIp
? (hasApiProxyDomain ? config.allowedDomains : [...config.allowedDomains, 'api-proxy'])

Copilot uses AI. Check for mistakes.
Comment on lines +1869 to +1881
try {
await writeConfigs(config);
} catch {
// May fail after writing configs
}

// Verify squid.conf includes api-proxy in allowed domains
const squidConfPath = path.join(testDir, 'squid.conf');
if (fs.existsSync(squidConfPath)) {
const content = fs.readFileSync(squidConfPath, 'utf-8');
expect(content).toContain('github.com');
expect(content).toContain('api-proxy');
}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

This test can pass without actually asserting anything: it swallows writeConfigs errors and then only checks the file contents if squid.conf exists. If writeConfigs fails before writing the config (e.g., missing seccomp profile), the if (fs.existsSync(...)) block is skipped and the test still passes. To make the coverage meaningful, ensure squid.conf is created (or mock the seccomp-profile copy) and assert existsSync is true, or spy on generateSquidConfig to verify the domains argument includes api-proxy.

This issue also appears on line 1894 of the same file.

Copilot uses AI. Check for mistakes.
lpcox added a commit that referenced this pull request Feb 13, 2026
…ng (#802)

* Initial plan

* fix(ci): add BASE_URL environment variables for CODEX api-proxy routing

CODEX was not being directed to use the api-proxy because the
OPENAI_BASE_URL and ANTHROPIC_BASE_URL environment variables were
not explicitly set in the smoke-codex workflow.

While AWF automatically sets these variables when generating the
docker-compose configuration (if API keys are present), explicitly
setting them in the workflow env ensures they are available to the
CODEX agent for routing API calls through the api-proxy sidecar.

This fix adds:
- OPENAI_BASE_URL=http://api-proxy:10000
- ANTHROPIC_BASE_URL=http://api-proxy:10001

to the 'Run Codex' step environment variables.

Fixes job failure in run 63483600453.

* fix(ci): remove API keys from agent env when api-proxy is enabled (#803)

* Initial plan

* fix(ci): remove API keys from agent env when api-proxy is enabled

When api-proxy is enabled (indicated by BASE_URL environment variables),
API keys should NOT be exposed to the agent container for security.
The api-proxy sidecar holds the credentials and injects auth headers.

Previously, the workflow was passing both:
- CODEX_API_KEY and OPENAI_API_KEY (should NOT be in agent env)
- OPENAI_BASE_URL and ANTHROPIC_BASE_URL (should be in agent env)

This defeated the security isolation provided by api-proxy.

Changes:
- Removed CODEX_API_KEY and OPENAI_API_KEY from agent environment block
- Kept OPENAI_BASE_URL and ANTHROPIC_BASE_URL for routing to api-proxy
- The awf CLI still receives keys via `sudo -E` and `--env-all`
- awf passes keys only to api-proxy container, not agent container

Security model:
- awf reads keys from host environment (process.env)
- awf passes keys only to api-proxy sidecar (src/docker-manager.ts:908-909)
- Agent only receives BASE_URL variables (src/docker-manager.ts:948-955)
- api-proxy injects auth headers and routes through Squid

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

---------

Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* fix(firewall): add api-proxy to allowed domains when enabled (#804)

* Initial plan

* fix(firewall): add api-proxy to allowed domains when enabled

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

---------

Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* fix(squid): handle bare hostnames without leading dot for api-proxy (#805)

* Initial plan

* fix(squid): handle bare hostnames without leading dot for api-proxy

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

---------

Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* fix(agent): enable direct api-proxy access and remove api key from env (#807)

* Initial plan

* fix(agent): enable direct api-proxy access and remove api key from env

- Add iptables bypass for api-proxy in setup-iptables.sh
- Pass AWF_ENABLE_API_PROXY env var from docker-manager.ts
- Remove ANTHROPIC_API_KEY from agent env in workflows
- Update postprocess script to strip API key from compiled workflows

Fixes agent->api-proxy connectivity and security vulnerability where
API key was exposed to agent container instead of isolated to api-proxy.

---------

Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>

* fix: pass ANTHROPIC_API_KEY to validation in all Claude workflows (#808)

* Initial plan

* fix: pass ANTHROPIC_API_KEY to validation step in smoke-claude workflow

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* fix: pass ANTHROPIC_API_KEY to validation in all Claude workflows

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

---------

Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* fix: only enable api-proxy when API keys are provided (#810)

* Initial plan

* fix: only enable api-proxy when API keys are provided

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* feat(workflow): enable api-proxy for smoke-claude workflow

- Add --enable-api-proxy flag to awf command
- Add --anthropic-api-key flag to pass API key to api-proxy sidecar
- Add ANTHROPIC_API_KEY to env block for agent step
- API key is shared with api-proxy, kept out of agent container
- Agent uses ANTHROPIC_BASE_URL to direct requests to api-proxy

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* refactor(workflow): remove redundant --enable-api-proxy flag

The --enable-api-proxy flag defaults to true (src/cli.ts:724), so it
doesn't need to be explicitly specified. The api-proxy sidecar will
automatically deploy when API keys are present.

See docs/api-proxy-sidecar.md:51 which states "The API proxy is
enabled by default and automatically deploys when API keys are present"

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

---------

Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* fix: remove unknown --anthropic-api-key flag from smoke-claude workflow (#811)

* Initial plan

* fix: remove unknown --anthropic-api-key flag from smoke-claude workflow

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

---------

Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* fix: use api-proxy IP address instead of hostname for BASE_URL (#813)

* Initial plan

* fix: use api-proxy IP address instead of hostname for BASE_URL

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

---------

Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* fix: use api-proxy IP address instead of hostname for BASE_URL (#813) (#815)

* Initial plan

* fix: use api-proxy IP address instead of hostname for BASE_URL (#813)

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

---------

Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* fix(api-proxy): use IP address for API base URLs to avoid DNS issues

In chroot mode, Docker container hostname resolution can fail because
the DNS resolver may not properly reach Docker's embedded DNS. Use the
api-proxy IP address directly (e.g., http://172.30.0.30:10001) instead
of the hostname (http://api-proxy:10001) to eliminate DNS resolution as
a failure point.

Also add test coverage for the host-iptables api-proxy ACCEPT rule.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: exclude API keys from agent when api-proxy is enabled (#814)

* Initial plan

* fix: exclude API keys from agent when api-proxy is enabled

---------

Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>

* fix(agent): use AWF_API_PROXY_IP env var for api-proxy iptables rules (#817)

* Initial plan

* fix(agent): use AWF_API_PROXY_IP env var for api-proxy iptables

Move api-proxy iptables rules to use pre-set AWF_API_PROXY_IP environment
variable instead of dynamic hostname resolution, and place FILTER rules in
the correct position (after NAT setup, before final DROP rule).

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

---------

Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* Add debug logging for BASE_URL environment variables in agent container (#816)

* Initial plan

* feat: add debug logging for BASE_URL environment variables

Add logging to display ANTHROPIC_BASE_URL and OPENAI_BASE_URL values
that are set for the agent container. This helps debug configuration
issues when running Claude Code CLI in the workflow.

The logging is added after the Docker Compose config is generated,
showing whether BASE_URL variables are set or using defaults.

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

---------

Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* fix: simplify api-proxy iptables bypass condition (#819)

* Initial plan

* fix: simplify api-proxy iptables bypass condition

The NAT bypass for api-proxy traffic was checking both AWF_ENABLE_API_PROXY
and AWF_API_PROXY_IP, but this was too strict. When the HTTP_PROXY
environment variable is set, HTTP clients will send requests through the
proxy unless NO_PROXY is configured or iptables rules prevent it.

The issue was that the NAT bypass required both flags, causing traffic
to 172.30.0.30 (api-proxy) to be sent through Squid when it should go
directly. Squid then blocked these requests because the IP address wasn't
in the domain whitelist.

The fix simplifies the condition to only check AWF_API_PROXY_IP, matching
the pattern used for the OUTPUT FILTER ACCEPT rules (lines 285-289).
This ensures that when AWF_API_PROXY_IP is set, traffic to that IP
bypasses Squid at the NAT level, preventing HTTP clients from routing
through the proxy regardless of HTTP_PROXY settings.

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

---------

Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* Initial plan (#818)

Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>

* fix: add api-proxy IP to squid allowlist (#820)

* Initial plan

* fix: add api-proxy IP to squid allowlist

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

---------

Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

---------

Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: Landon Cox <landon.cox@microsoft.com>
Co-authored-by: Jiaxiao (mossaka) Zhou <duibao55328@gmail.com>
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.

2 participants