or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

authentication.mdhttp-client.mdindex.mdproxy-support.md
tile.json

proxy-support.mddocs/

Proxy Support

Automatic proxy detection and configuration based on standard environment variables with intelligent bypass rules for local addresses. The proxy system integrates seamlessly with GitHub Actions runners and supports both HTTP and HTTPS proxies.

Capabilities

Proxy URL Detection

Automatically detects proxy configuration from environment variables.

/**
 * Get proxy URL for a server URL based on environment variables
 * Checks https_proxy/HTTPS_PROXY for HTTPS URLs, http_proxy/HTTP_PROXY for HTTP URLs
 * @param serverUrl - Target server URL
 * @returns Proxy URL string or empty string if no proxy needed
 */
function getProxyUrl(serverUrl: string): string;

Internal Proxy Detection (from proxy submodule)

Core proxy detection logic working with URL objects. Available from '@actions/http-client/lib/proxy'.

/**
 * Internal proxy detection function working with URL objects (from proxy submodule)
 * @param reqUrl - Request URL object
 * @returns Proxy URL object or undefined if no proxy needed
 */
function getProxyUrl(reqUrl: URL): URL | undefined;

Bypass Detection (from proxy submodule)

Determines if a URL should bypass proxy based on no_proxy configuration. Available from '@actions/http-client/lib/proxy'.

/**
 * Check if URL should bypass proxy based on no_proxy/NO_PROXY environment variable
 * Supports wildcards, domain matching, and port-specific rules
 * @param reqUrl - Request URL to check
 * @returns True if URL should bypass proxy
 */
function checkBypass(reqUrl: URL): boolean;

Usage Examples:

import { HttpClient, getProxyUrl } from "@actions/http-client";
import { getProxyUrl as getProxyUrlInternal, checkBypass } from "@actions/http-client/lib/proxy";

// Check if proxy is configured for a URL
const proxyUrl = getProxyUrl("https://api.github.com");
if (proxyUrl) {
  console.log(`Using proxy: ${proxyUrl}`);
} else {
  console.log("No proxy configured");
}

// HttpClient automatically uses proxy
const client = new HttpClient("my-action/1.0");
const response = await client.get("https://api.example.com/data");
// Automatically uses proxy if configured via environment variables

Environment Variables

The proxy system reads standard proxy environment variables:

Proxy Configuration

  • http_proxy or HTTP_PROXY: Proxy URL for HTTP requests
  • https_proxy or HTTPS_PROXY: Proxy URL for HTTPS requests

Bypass Configuration

  • no_proxy or NO_PROXY: Comma-separated list of hosts to bypass proxy

Environment Variable Examples:

# Basic proxy configuration
export http_proxy=http://proxy.company.com:8080
export https_proxy=http://proxy.company.com:8080

# Proxy with authentication
export https_proxy=http://username:password@proxy.company.com:8080

# Bypass rules
export no_proxy=localhost,127.0.0.1,.company.com,internal.server:3000

# Complete proxy setup
export http_proxy=http://proxy.company.com:8080
export https_proxy=http://proxy.company.com:8080
export no_proxy=localhost,127.0.0.1,.internal,.company.com,192.168.*

Bypass Rules

The no_proxy environment variable supports various patterns:

Supported Patterns

  1. Exact hostname: localhost, api.internal.com
  2. Domain suffix: .company.com (matches all subdomains)
  3. Wildcard: * (bypasses all requests)
  4. IP addresses: 127.0.0.1, 192.168.1.1
  5. Port-specific: internal.server:3000
  6. IP ranges: Limited support for pattern matching

Automatic Bypass

The following addresses automatically bypass proxy:

  • Loopback addresses: localhost, 127.0.0.1, [::1], [0:0:0:0:0:0:0:1]
  • Local IPv6: Any address starting with [::1] or [0:0:0:0:0:0:0:1]

Bypass Examples:

import { checkBypass } from "@actions/http-client/lib/proxy";

// Using internal proxy functions
const url = new URL("https://api.github.com");
const internalProxyUrl = getProxyUrlInternal(url);
const shouldBypass = checkBypass(url);

console.log(`Internal proxy URL:`, internalProxyUrl?.href);
console.log(`Should bypass:`, shouldBypass);

// These will bypass proxy automatically
console.log(checkBypass(new URL("http://localhost:3000"))); // true
console.log(checkBypass(new URL("http://127.0.0.1:8080"))); // true

// With no_proxy=".company.com,internal.server:3000"
console.log(checkBypass(new URL("https://api.company.com"))); // true
console.log(checkBypass(new URL("http://internal.server:3000"))); // true
console.log(checkBypass(new URL("http://internal.server:8080"))); // false
console.log(checkBypass(new URL("https://external.api.com"))); // false

Proxy Integration

The HttpClient automatically integrates proxy support:

  1. Automatic Detection: Checks environment variables for each request
  2. Protocol Matching: Uses https_proxy for HTTPS URLs, http_proxy for HTTP URLs
  3. Bypass Checking: Applies no_proxy rules before using proxy
  4. Agent Creation: Creates appropriate tunnel agents for proxy connections
  5. Authentication: Supports proxy authentication via URL credentials

GitHub Actions Integration

In GitHub Actions runners, proxy configuration is typically handled by the runner environment:

# .github/workflows/action.yml
name: My Action
on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Run with proxy
        env:
          http_proxy: ${{ secrets.HTTP_PROXY }}
          https_proxy: ${{ secrets.HTTPS_PROXY }}
          no_proxy: localhost,127.0.0.1,.company.com
        run: |
          # Your action code here
          # HttpClient will automatically use proxy configuration

Advanced Proxy Usage:

import { HttpClient } from "@actions/http-client";

// Client automatically handles proxy configuration
const client = new HttpClient("my-action/1.0", [], {
  // These options work with proxy
  keepAlive: true,          // Connection pooling through proxy
  maxSockets: 50,           // Limit concurrent proxy connections
  socketTimeout: 30000,     // Timeout for proxy connections
  allowRetries: true,       // Retry through proxy on failure
  maxRetries: 3
});

// All requests automatically use proxy if configured
const response1 = await client.get("https://api.github.com/user");
const response2 = await client.get("https://external-api.com/data");
const response3 = await client.get("http://localhost:3000/health"); // Bypasses proxy

// Manual proxy detection for logging
const githubProxy = getProxyUrl("https://api.github.com");
const localProxy = getProxyUrl("http://localhost:3000");

console.log(`GitHub API proxy: ${githubProxy || "none"}`);
console.log(`Local API proxy: ${localProxy || "none"}`);

// Custom proxy configuration (not recommended - use environment variables)
const customClient = new HttpClient("my-action/1.0", [], {
  // Note: HttpClient doesn't expose proxy configuration directly
  // Always use environment variables for proxy configuration
});

Proxy Authentication

Proxy authentication is supported via URL credentials in the proxy environment variables:

# Username and password in proxy URL
export https_proxy=http://username:password@proxy.company.com:8080

# URL-encoded credentials for special characters
export https_proxy=http://user%40domain:p%40ssw0rd@proxy.company.com:8080

The client automatically extracts and applies proxy credentials using the DecodedURL class internally, which properly handles URL decoding of usernames and passwords.