Skip to content

Proxy and VPN Configuration

Many enterprise environments require proxy configurations or VPN connections. This guide covers how to configure Claude Code to work seamlessly in restricted network environments.

HTTP/HTTPS Proxy

Forward all traffic through corporate proxy server for security and monitoring

SOCKS Proxy

Route traffic through SOCKS proxy for additional protocols and flexibility

VPN Required

Connect to corporate VPN before accessing internal resources or internet

Certificate Authentication

Use corporate certificates for proxy authentication and SSL inspection

  1. Set HTTP/HTTPS proxy

    Terminal window
    # Linux/macOS
    export HTTP_PROXY=http://proxy.company.com:8080
    export HTTPS_PROXY=http://proxy.company.com:8080
    export http_proxy=$HTTP_PROXY
    export https_proxy=$HTTPS_PROXY
    # Windows (Command Prompt)
    set HTTP_PROXY=http://proxy.company.com:8080
    set HTTPS_PROXY=http://proxy.company.com:8080
    # Windows (PowerShell)
    $env:HTTP_PROXY="http://proxy.company.com:8080"
    $env:HTTPS_PROXY="http://proxy.company.com:8080"
  2. Configure no-proxy exceptions

    Terminal window
    # Internal domains that shouldn't go through proxy
    export NO_PROXY=localhost,127.0.0.1,*.internal.company.com,10.0.0.0/8
    # Windows
    set NO_PROXY=localhost,127.0.0.1,*.internal.company.com,10.0.0.0/8
  3. Verify configuration

    Terminal window
    # Test proxy connectivity
    claude "Test my network configuration and verify:
    - Proxy settings are detected
    - Can reach external APIs
    - DNS resolution works
    - Certificate validation passes"
Terminal window
# Include credentials in proxy URL
export HTTP_PROXY=http://username:password@proxy.company.com:8080
export HTTPS_PROXY=http://username:password@proxy.company.com:8080
# More secure: use encoded credentials
export HTTP_PROXY=http://$(echo -n username:password | base64)@proxy.company.com:8080
  1. Export corporate certificates

    Terminal window
    # Get certificate from IT department or export from browser
    # Usually in .crt, .pem, or .cer format
  2. Install certificates system-wide

    Terminal window
    # Copy certificate to system store
    sudo cp corporate-ca.crt /usr/local/share/ca-certificates/
    sudo update-ca-certificates
    # For RHEL/CentOS
    sudo cp corporate-ca.crt /etc/pki/ca-trust/source/anchors/
    sudo update-ca-trust
  3. Configure Node.js to use certificates

    Terminal window
    # Point to certificate bundle
    export NODE_EXTRA_CA_CERTS=/path/to/corporate-ca.crt
    # Or disable SSL verification (NOT recommended for production)
    export NODE_TLS_REJECT_UNAUTHORIZED=0
Terminal window
# Temporary SSL bypass for testing
claude --no-verify-ssl "Your command here"
# Configure git to work with corporate proxy
git config --global http.proxy http://proxy.company.com:8080
git config --global https.proxy http://proxy.company.com:8080
git config --global http.sslVerify false # Only if necessary

Optimizing VPN Usage

Terminal window
# Check routing table to understand VPN impact
claude "Analyze my network routing:
- Show current routes
- Identify VPN interfaces
- Check which traffic goes through VPN
- Suggest optimizations for Claude Code"
# Configure Claude Code to use direct internet when possible
export CLAUDE_DIRECT_CONNECTION=true # If supported
  1. Automated VPN connection

    vpn-connect.sh
    #!/bin/bash
    # Connect to VPN
    echo "Connecting to corporate VPN..."
    /opt/cisco/anyconnect/bin/vpn -s connect vpn.company.com << EOF
    username
    password
    y
    EOF
    # Wait for connection
    sleep 5
    # Verify connection
    if ip addr show | grep -q "vpn0"; then
    echo "VPN connected successfully"
    # Set proxy for VPN network
    export HTTP_PROXY=http://internal-proxy:8080
    export HTTPS_PROXY=http://internal-proxy:8080
    # Start Claude Code session
    claude "VPN connected, ready for work"
    else
    echo "VPN connection failed"
    exit 1
    fi
  2. VPN disconnect cleanup

    vpn-disconnect.sh
    #!/bin/bash
    # Disconnect VPN
    /opt/cisco/anyconnect/bin/vpn disconnect
    # Clear proxy settings
    unset HTTP_PROXY
    unset HTTPS_PROXY
    echo "VPN disconnected, proxy settings cleared"
Terminal window
# For SOCKS5 proxy
export ALL_PROXY=socks5://proxy.company.com:1080
export all_proxy=$ALL_PROXY
# With authentication
export ALL_PROXY=socks5://username:password@proxy.company.com:1080
# SSH tunnel as SOCKS proxy
ssh -D 1080 -N jumphost.company.com
export ALL_PROXY=socks5://localhost:1080

Proxy Auto-Configuration

// Example PAC file logic
function FindProxyForURL(url, host) {
// Direct connection for internal sites
if (isInNet(host, "10.0.0.0", "255.0.0.0") ||
dnsDomainIs(host, ".internal.company.com")) {
return "DIRECT";
}
// Use proxy for external sites
return "PROXY proxy.company.com:8080";
}
Terminal window
# Use PAC file with Claude Code
export AUTO_PROXY=http://proxy.company.com/proxy.pac
# Parse PAC file manually if needed
claude "Parse this PAC file and extract:
- Proxy rules
- Direct connection domains
- Create equivalent environment variables"
Terminal window
# Increase timeout values
export CLAUDE_TIMEOUT=300 # 5 minutes
# Test connectivity
claude "Debug my connection issues:
- Test proxy connectivity
- Check DNS resolution
- Verify SSL handshake
- Measure latency"
  1. Network diagnostics

    Terminal window
    claude "Run comprehensive network diagnostics:
    - Show all network interfaces
    - Display routing table
    - Check DNS servers
    - Test proxy connectivity
    - Verify certificate stores
    - Check environment variables"
  2. Proxy test script

    Terminal window
    claude "Create a proxy test script that:
    - Tests HTTP/HTTPS connectivity
    - Verifies proxy authentication
    - Checks SSL certificate validation
    - Measures response times
    - Tests Claude Code API access"
  3. Environment validation

    Terminal window
    claude "Validate my environment for Claude Code:
    - Check all proxy variables
    - Verify certificate configuration
    - Test API endpoints
    - Check for conflicts
    - Generate report"

Local Caching Proxy

Terminal window
# Install Squid as local caching proxy
sudo apt-get install squid
# Configure Squid to cache Claude Code requests
claude "Configure Squid proxy for:
- Cache API responses where appropriate
- Forward to corporate proxy
- Handle SSL bumping if needed
- Optimize for Claude Code usage"
Terminal window
# Configure connection reuse
export CLAUDE_KEEP_ALIVE=true
export CLAUDE_MAX_SOCKETS=10
# For better performance through proxy
export HTTP_KEEP_ALIVE=true
export HTTPS_KEEP_ALIVE=true
Terminal window
# Use secret-tool for credential storage
echo -n "proxy-password" | secret-tool store \
--label="Corporate Proxy" \
service proxy \
username myusername
# Retrieve in script
PROXY_PASS=$(secret-tool lookup service proxy username myusername)
export HTTP_PROXY="http://myusername:${PROXY_PASS}@proxy.company.com:8080"

Master more enterprise features:

Remember: Proxy configuration can be complex in enterprise environments. Always work with your IT team to ensure compliance with security policies while maintaining productivity with Claude Code.