Skip to content

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

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

fix: add api-proxy IP to squid allowlist#820
lpcox merged 2 commits intoclaude/fix-github-actions-workflow-againfrom
claude/fix-github-actions-workflow-one-more-time

Conversation

@Claude
Copy link
Contributor

@Claude Claude AI commented Feb 13, 2026

Squid was blocking traffic to the api-proxy sidecar because only the hostname 'api-proxy' was in the allowlist, not its IP address 172.30.0.30. Some HTTP clients bypass NO_PROXY settings or use the IP directly when BASE_URL environment variables contain IPs.

Changes

  • src/docker-manager.ts: Add both hostname and IP to Squid allowlist when api-proxy is enabled

    const domainsForSquid = config.enableApiProxy && networkConfig.proxyIp && (config.openaiApiKey || config.anthropicApiKey)
      ? [...config.allowedDomains, 'api-proxy', networkConfig.proxyIp]  // Now includes IP
      : config.allowedDomains;
  • src/docker-manager.test.ts: Verify IP appears in generated Squid config

  • src/host-iptables.test.ts: Remove invalid test calling setupHostIptables with incorrect signature (4 params instead of 3)

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/repos/github/gh-aw-firewall/actions/jobs/63495506647
    • Triggering command: /usr/bin/gh gh run view 21978551088 --job 63495506647 --log (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
@Claude Claude AI changed the title [WIP] Fix failing GitHub Actions workflow agent fix: add api-proxy IP to squid allowlist Feb 13, 2026
@Claude Claude AI requested a review from lpcox February 13, 2026 07:42
@lpcox lpcox marked this pull request as ready for review February 13, 2026 07:42
Copilot AI review requested due to automatic review settings February 13, 2026 07:42
@lpcox lpcox merged commit a2b8d67 into claude/fix-github-actions-workflow-again Feb 13, 2026
@lpcox lpcox deleted the claude/fix-github-actions-workflow-one-more-time branch February 13, 2026 07:42
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

This PR attempts to fix Squid blocking traffic to the api-proxy sidecar by adding the api-proxy IP address (172.30.0.30) to the Squid allowlist, addressing cases where HTTP clients bypass NO_PROXY settings or use the IP directly from BASE_URL environment variables.

Changes:

  • Added api-proxy IP address (172.30.0.30) to Squid allowlist alongside the hostname
  • Added test to verify IP appears in Squid config
  • Removed invalid test that called setupHostIptables with incorrect 4-parameter signature

Reviewed changes

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

File Description
src/docker-manager.ts Adds api-proxy IP to domains array for Squid allowlist (lines 1150-1153)
src/docker-manager.test.ts Adds test assertion to verify IP appears in squid.conf (line 1915)
src/host-iptables.test.ts Removes invalid test calling setupHostIptables with 4 params instead of 3 (lines 229-259 removed)

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

Comment on lines +1909 to +1915
// Verify squid.conf includes api-proxy hostname and IP 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');
expect(content).toContain('172.30.0.30'); // api-proxy IP address
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 verifies that the IP address '172.30.0.30' appears in the Squid config, but it doesn't verify that the IP is correctly formatted for Squid ACLs. Squid's dstdomain ACL type does not match IP addresses - only domain names. IP addresses require the 'dst' ACL type. The test should verify that the IP appears in a 'dst' ACL, not a 'dstdomain' ACL, or alternatively verify that the IP is NOT added if the design is to rely solely on NO_PROXY for direct connections.

Suggested change
// Verify squid.conf includes api-proxy hostname and IP 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');
expect(content).toContain('172.30.0.30'); // api-proxy IP address
// Verify squid.conf includes api-proxy hostname and IP in allowed ACLs
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');
expect(content).toMatch(/^acl\s+\S+\s+dst\s+172\.30\.0\.30/m); // api-proxy IP address in dst ACL

Copilot uses AI. Check for mistakes.
// The IP address is necessary because some tools may bypass NO_PROXY settings or use the IP directly
const domainsForSquid = config.enableApiProxy && networkConfig.proxyIp && (config.openaiApiKey || config.anthropicApiKey)
? [...config.allowedDomains, 'api-proxy']
? [...config.allowedDomains, 'api-proxy', networkConfig.proxyIp]
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.

IP addresses cannot be properly handled by Squid's dstdomain ACL type. The current implementation adds the IP address to the domains array, which will be processed by formatDomainForSquid() and used with the 'dstdomain' ACL. However, Squid's dstdomain ACL is designed for domain names and will not match IP addresses. For IP addresses, Squid requires the 'dst' ACL type instead.

Additionally, formatDomainForSquid() will incorrectly add a leading dot to the IP address (e.g., ".172.30.0.30") since it contains dots, which is semantically incorrect for an IP.

To fix this, IP addresses should either be:

  1. Handled separately and added to Squid config using 'acl allowed_ips dst' instead of 'acl allowed_domains dstdomain', or
  2. Not added to Squid allowlist at all if NO_PROXY is sufficient (which is the intended design based on comments at lines 966-975)

See below for a potential fix:

  // When API proxy is enabled and has API keys, add api-proxy hostname to allowed domains so the agent can communicate with it
  const domainsForSquid = config.enableApiProxy && networkConfig.proxyIp && (config.openaiApiKey || config.anthropicApiKey)
    ? [...config.allowedDomains, 'api-proxy']

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