v1.9.4-99ab90b
← Back to Hex Proxies

Proxy Authentication Protocols

Proxy authentication determines how clients prove their identity to a proxy server. This guide covers all major authentication methods — Basic, Digest, IP whitelisting, and token-based — with security trade-offs and implementation guidance.

Technical Details

Proxy authentication methods defined by HTTP standards and common implementations: 1. Basic Authentication (RFC 7617): - Client sends: Proxy-Authorization: Basic base64(username:password) - Credentials encoded (NOT encrypted) in Base64 - Server responds with 407 Proxy Authentication Required if missing/invalid - Challenge header: Proxy-Authenticate: Basic realm="proxy" - Simple but credentials are effectively cleartext 2. Digest Authentication (RFC 7616): - Challenge-response mechanism using MD5/SHA-256 hashing - Server sends nonce in 407 response - Client computes: response = hash(hash(user:realm:pass):nonce:hash(method:uri)) - Prevents replay attacks through nonce freshness - Does not protect message body 3. IP Whitelisting: - Proxy allows connections from pre-authorized IP addresses - No in-band authentication — access is granted by source IP - Requires static or predictable client IPs - Often combined with other methods as a defense-in-depth layer 4. Token-Based Authentication: - Client includes an API key or bearer token in proxy headers - More flexible than Basic auth for programmatic access - Tokens can be rotated without changing passwords - Can encode permissions, expiry, and rate limits in the token 5. SOCKS5 Username/Password (RFC 1929): - Binary sub-negotiation after SOCKS5 method selection - Username and password sent in cleartext within the sub-negotiation - Simpler than HTTP auth but same cleartext concern 6. Mutual TLS (mTLS): - Client presents a certificate to the proxy during TLS handshake - Strongest authentication — cryptographic proof of identity - Complex certificate management overhead

Advantages

  • Basic Auth: universally supported, trivial to implement
  • Digest Auth: prevents credential replay without TLS
  • IP Whitelisting: zero in-band overhead, no credentials in transit
  • Token Auth: supports rotation, scoping, and expiry
  • mTLS: strongest cryptographic authentication available
  • Layered approaches combine multiple methods for defense in depth

Disadvantages

  • Basic Auth: credentials are effectively cleartext (Base64 is not encryption)
  • Digest Auth: complex implementation, MD5 is considered weak
  • IP Whitelisting: inflexible for dynamic/cloud environments
  • Token Auth: tokens must be securely stored and rotated
  • mTLS: certificate lifecycle management adds operational complexity
  • No single method is perfect — security depends on transport encryption

Use Cases

  • 1Securing commercial proxy access with user credentials
  • 2Enterprise proxy deployments with centralized access control
  • 3API-based proxy access with token rotation
  • 4Serverless environments where IP whitelisting is impractical
  • 5High-security environments requiring mutual TLS
  • 6Multi-tenant proxy platforms with per-user authentication

Code Example

# Basic Authentication
curl -x http://USER:PASS@gate.hexproxies.com:8080 https://httpbin.org/ip

# IP Whitelist (no credentials needed after whitelisting your IP)
curl -x http://gate.hexproxies.com:8080 https://httpbin.org/ip

# Python — Basic Auth with requests
import requests
proxies = {"https": "http://USER:PASS@gate.hexproxies.com:8080"}
response = requests.get("https://httpbin.org/ip", proxies=proxies)

# Python — environment variable credentials (security best practice)
import os
import requests

proxy_user = os.environ["HEX_PROXY_USER"]
proxy_pass = os.environ["HEX_PROXY_PASS"]
proxies = {"https": f"http://{proxy_user}:{proxy_pass}@gate.hexproxies.com:8080"}
response = requests.get("https://httpbin.org/ip", proxies=proxies)

# Node.js — API key authentication
const { HttpsProxyAgent } = require('https-proxy-agent');

const apiKey = process.env.HEX_API_KEY;
const agent = new HttpsProxyAgent(
  `http://${apiKey}:${apiKey}@gate.hexproxies.com:8080`
);

const response = await fetch('https://httpbin.org/ip', { agent });
console.log(await response.json());

# SOCKS5 username/password authentication
curl --socks5-hostname USER:PASS@gate.hexproxies.com:1080 https://httpbin.org/ip

Proxy Authentication Deep Dive

Authentication is the gateway to any proxy service. Understanding how different authentication methods work — their strengths, weaknesses, and appropriate use cases — is essential for building secure proxy infrastructure. This guide covers every major authentication protocol used in proxy deployments today.

Why Proxy Authentication Matters

Without authentication, anyone who discovers your proxy endpoint can use it. This creates security risks (unauthorized access to your IP pool), financial risks (bandwidth and IP usage costs), and legal risks (your IPs used for malicious activity). Proper authentication ensures that only authorized clients can route traffic through your proxy infrastructure.

Basic Authentication

Basic Authentication is the most common method for HTTP proxy access. It is defined in RFC 7617 and works as follows:

  1. Client sends a request without credentials
  2. Proxy responds with `407 Proxy Authentication Required` and a `Proxy-Authenticate: Basic realm="proxy"` header
  3. Client resends the request with `Proxy-Authorization: Basic <credentials>`, where credentials are `base64(username:password)`

**Security reality**: Base64 is an encoding, not encryption. The credentials `user:pass` become `dXNlcjpwYXNz` — trivially reversible. This means Basic Auth provides no confidentiality on its own. However, when combined with TLS (HTTPS to the proxy), the credentials are protected by the encrypted transport.

**When Basic Auth is acceptable**: - The connection to the proxy is encrypted (TLS) - The proxy is on a private network - Simplicity is more important than credential protection (development environments)

Digest Authentication

Digest Authentication (RFC 7616) is a challenge-response protocol that avoids sending credentials in cleartext:

  1. Client sends a request without credentials
  2. Proxy responds with a 407 containing a nonce: `Proxy-Authenticate: Digest realm="proxy", nonce="abc123", qop="auth"`
  3. Client computes a hash: `MD5(MD5(user:realm:pass):nonce:nc:cnonce:qop:MD5(method:uri))`
  4. Client sends the hash in `Proxy-Authorization: Digest ...`

The proxy performs the same computation and compares results. The password never traverses the network — only a hash of the password combined with a one-time nonce.

**Advantages over Basic**: prevents credential replay, works without TLS for credential protection. **Disadvantages**: complex to implement correctly, relies on MD5 (deprecated for security), still does not protect the request body.

IP Whitelisting

IP whitelisting is the simplest form of access control — the proxy accepts connections from pre-authorized IP addresses and rejects everything else. No in-band credentials are needed.

**How it works with Hex Proxies**: 1. Log into your Hex Proxies dashboard 2. Navigate to authentication settings 3. Add your server's public IP address to the whitelist 4. Connect to the proxy without username/password

**Benefits**: zero overhead per request, no credentials to leak, no authentication headers to configure. **Drawbacks**: requires static IPs, impractical for serverless or edge deployments, provides no per-user tracking in multi-user setups.

Token-Based Authentication

Token-based authentication uses API keys or bearer tokens instead of traditional username/password pairs. Tokens offer several advantages for programmatic proxy access:

  • **Rotation**: tokens can be rotated without changing the primary account password
  • **Scoping**: tokens can be limited to specific proxy types, regions, or bandwidth quotas
  • **Expiry**: tokens can have built-in expiration dates
  • **Revocation**: individual tokens can be revoked without affecting others

Hex Proxies supports API key authentication for all proxy types. Your API key serves as both username and password, simplifying configuration while maintaining security.

SOCKS5 Authentication

SOCKS5 uses its own authentication sub-protocol defined in RFC 1929. After the method negotiation phase selects username/password authentication (method 0x02), a sub-negotiation occurs:

Client → Proxy: [0x01] [uname_len] [uname] [passwd_len] [passwd]
Proxy → Client: [0x01] [0x00]  (success)

Like HTTP Basic Auth, credentials are in cleartext. The same recommendation applies: use TLS wrapping or operate on trusted networks.

Mutual TLS (mTLS)

Mutual TLS provides the strongest authentication available. Both the client and proxy present X.509 certificates during the TLS handshake, providing cryptographic proof of identity:

  1. Standard TLS handshake begins — proxy presents its certificate
  2. Proxy requests client certificate (`CertificateRequest` message)
  3. Client presents its certificate
  4. Both sides verify certificate chains against trusted CAs
  5. Connection is established with mutual authentication

mTLS eliminates credential theft risks entirely — there are no passwords or tokens to steal. The trade-off is operational complexity: certificate issuance, distribution, renewal, and revocation must be managed.

Hex Proxies Authentication

Hex Proxies supports multiple authentication methods to fit different deployment scenarios:

  • **Username/Password**: Standard Basic Auth over the proxy connection — works with HTTP and SOCKS5
  • **IP Whitelisting**: Add authorized IPs through the dashboard for credential-free access
  • **API Keys**: Generate scoped API keys for programmatic access with rotation support

All methods work with all proxy types (residential, ISP, datacenter, premium residential) through the unified gateway at `gate.hexproxies.com`.

Security Best Practices

  1. Always use TLS for the connection to the proxy when using Basic Auth
  2. Rotate credentials regularly — at minimum every 90 days
  3. Use IP whitelisting as an additional layer on top of credential auth
  4. Store proxy credentials in environment variables or secret managers, never in source code
  5. Monitor authentication failures for brute-force detection
  6. Use the most restrictive auth method your architecture supports

Ready to Get Started?

Use Proxy Authentication Protocols with Hex Proxies for reliable, fast connections.

Cookie Preferences

We use cookies to ensure the best experience. You can customize your preferences below. Learn more