Skip to content
Fixedmark
Docs

PHP HTTPS proxy setup

PHP clients built on libcurl, including Guzzle and the cURL extension, accept the Fixedmark https:// proxy URL directly. Check that your libcurl build supports HTTPS proxies.

Docs preview: Fixedmark is not live yet. Endpoints are issued at launch, and these pages describe planned launch behavior. Anything marked planned may change. Join early access to get yours first.

Guzzle

Pass the proxy URL in the proxy request option. The array form sets a proxy per scheme and a no list for hosts that should go direct.

<?php
// composer require guzzlehttp/guzzle
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client([
    'proxy' => [
        'http'  => getenv('FIXEDMARK_PROXY_URL'),
        'https' => getenv('FIXEDMARK_PROXY_URL'),
        'no'    => ['localhost', '127.0.0.1'],
    ],
    'connect_timeout' => 10,
    'timeout' => 30,
]);

$res = $client->get('https://api.partner.example/v1/orders');
echo $res->getStatusCode(), PHP_EOL;

Laravel's Http facade wraps Guzzle, so Http::withOptions(['proxy' => ...]) takes the same value.

cURL extension

Set CURLOPT_PROXY to the full URL. libcurl reads the scheme and credentials from it and tunnels HTTPS with CONNECT.

<?php
$ch = curl_init('https://api.partner.example/v1/orders');
curl_setopt_array($ch, [
    CURLOPT_PROXY          => getenv('FIXEDMARK_PROXY_URL'),
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT        => 30,
]);

$body = curl_exec($ch);
if ($body === false) {
    fwrite(STDERR, curl_error($ch) . PHP_EOL);
    exit(1);
}
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), PHP_EOL;

Check libcurl support

HTTPS proxies need libcurl 7.52.0 or later, built with a TLS backend that supports them. Most current Linux images qualify. Check before you deploy:

# libcurl 7.52.0+ with HTTPS-proxy support is required.
curl -V | grep -o HTTPS-proxy

php -r 'var_dump((bool) (curl_version()["features"] & CURL_VERSION_HTTPS_PROXY));'

Notes

  • Guzzle's stream handler, used only when the cURL extension is missing, does not support HTTPS proxies. Install ext-curl.
  • PHP-FPM workers keep cURL handles only for one request. Each request opens a new tunnel and counts as a new proxy request.
  • Set connect_timeout and timeout. A destination that silently drops non-allowlisted IPs otherwise hangs a worker.
  • For MySQL or Postgres from PHP, see databases. PDO has no proxy option.
Tested with PHP 8.5, the cURL extension, and Guzzle 7 against a local TLS-wrapped CONNECT proxy.

Platform guides

Frequently asked questions

Does Guzzle support an HTTPS proxy?

Yes, when it uses its default cURL handler and libcurl is 7.52.0 or later with HTTPS-proxy support. Guzzle passes the proxy URL to libcurl, which opens TLS to the proxy.

How do I check if PHP's libcurl supports HTTPS proxies?

Check that curl_version()['features'] includes the CURL_VERSION_HTTPS_PROXY bit. The constant exists from PHP 7.3.0 and cURL 7.52.0.

Can Laravel's HTTP client use the proxy?

Laravel's HTTP client is built on Guzzle. Pass the same proxy option with withOptions(['proxy' => ...]).

Make it fixed.

Fixedmark is in early access. Join the list to get dedicated static IPs when your region opens.