Skip to content

Feature: Add global HTTP proxy support via environment variables #43821

@mbC6zC

Description

@mbC6zC

Feature Request

Summary

Add comprehensive HTTP proxy support for all network requests made by OpenClaw, configurable through standard environment variables (HTTP_PROXY, HTTPS_PROXY, NO_PROXY).

Motivation

Many enterprise and restricted network environments require HTTP/HTTPS proxies for external internet access. Currently, OpenClaw does not respect standard proxy environment variables, making it difficult to deploy in such environments without manual proxy configuration for each service.

Proposed Solution

Implement global proxy support that:

  1. Reads standard proxy environment variables (HTTP_PROXY, HTTPS_PROXY, http_proxy, https_proxy)
  2. Supports NO_PROXY bypass rules for local/internal services
  3. Uses undici's ProxyAgent for consistent proxy handling across all HTTP requests
  4. Automatically applies to web fetch, web search, and all external API calls
  5. Validates proxy URL format and logs warnings for misconfigurations

Benefits

  • Enterprise Compatibility: Works seamlessly in corporate proxy environments
  • Zero Configuration: Respects existing environment variable conventions
  • Consistent Behavior: All network operations honor proxy settings automatically
  • Debugging Friendly: Clear logging for proxy configuration issues
  • Standard Compliant: Follows Unix/Linux proxy environment variable conventions

Use Cases

  • Corporate networks requiring HTTP proxy for internet access
  • Deployments behind application-level proxies
  • Testing and debugging through proxy tools (Burp, Charles, etc.)
  • Geographically restricted content access
  • Network monitoring and traffic analysis

Implementation Details

The implementation includes:

  • src/infra/net/proxy.ts: Core proxy resolution and agent creation
  • src/infra/net/bootstrap.ts: Bootstrap logic for global proxy setup
  • src/infra/net/proxy.test.ts: Comprehensive test coverage
  • Integration with existing fetch infrastructure
  • Support for multiple proxy protocols (http, https, socks4, socks5)

Configuration Example

export HTTP_PROXY=http://proxy.example.com:8080
export HTTPS_PROXY=http://proxy.example.com:8080
export NO_PROXY=localhost,127.0.0.1,.local,.internal
openclaw gateway run

Alternatives Considered

  1. Per-service proxy configuration: Rejected due to complexity
  2. Config file only: Rejected to maintain consistency with standard tools
  3. No proxy support: Not viable for enterprise deployments

Additional Context

This feature is particularly important for:

  • Users in China/Great Firewall regions
  • Enterprise environments with mandatory proxy requirements
  • Educational institutions with network restrictions
  • Any deployment requiring traffic monitoring/filtering

The implementation is backward compatible and only activates when proxy environment variables are explicitly set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions