PHP cURL extension for HTTP requests through KnoxProxy. Two cURL options and your scraper is proxied.
Use CURLOPT_PROXY.
$ch = curl_init("https://httpbin.org/ip");
curl_setopt($ch, CURLOPT_PROXY, "http://gw.knoxproxy.com:7000");
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "USER:PASS");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);Run the request.
$response = curl_exec($ch);
curl_close($ch);
echo $response;Add country to username.
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "USER-country-de:PASS");Use SOCKS5 proxy type.
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($ch, CURLOPT_PROXY, "gw.knoxproxy.com:7001");Check for errors.
if (curl_errno($ch)) {
echo "Error: " . curl_error($ch);
}Verify exit IP.
echo $response;<?php
/**
* KnoxProxy + PHP cURL -- complete working example.
*/
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => "https://httpbin.org/ip",
CURLOPT_PROXY => "http://gw.knoxproxy.com:7000",
CURLOPT_PROXYUSERPWD => "USER:PASS",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => true,
]);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo "Error: " . curl_error($ch) . "\n";
} else {
echo "Exit IP: " . $response . "\n";
}
curl_close($ch);
// Country-targeted request
$ch = curl_init("https://httpbin.org/ip");
curl_setopt($ch, CURLOPT_PROXY, "http://gw.knoxproxy.com:7000");
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "USER-country-us:PASS");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
echo "US IP: " . $response;
curl_close($ch);Each curl_exec() gets a new IP. For sticky sessions, add -session-{id} to the username.
| Problem | Fix |
|---|---|
| CURLE_COULDNT_CONNECT | Verify host, port, and firewall. |
| HTTP 407 | Check CURLOPT_PROXYUSERPWD format: USER:PASS. |
USER-country-de-city-berlin-session-profile07Order matters -- geo flags before the session flag. The session name is free text; use the profile ID so the mapping is self-documenting. Password stays as issued; no flags belong there. HTTP on :7000, SOCKS5 on :7001, same credentials.
Yes. Guzzle wraps the PHP cURL extension under the hood, so it accepts the same proxy address format. Pass ["proxy" => "http://USER:PASS@gw.knoxproxy.com:7000"] in the request options array on any Guzzle call, and Guzzle translates that into the equivalent CURLOPT_PROXY and CURLOPT_PROXYUSERPWD settings used in the raw cURL example above.
PHP handles this with curl_multi rather than true async, running several cURL handles concurrently inside one multi stack. Set CURLOPT_PROXY and CURLOPT_PROXYUSERPWD on each individual handle before adding it to the stack, and every handle gets its own KnoxProxy exit IP, useful for parallel scraping without spawning separate processes.
Yes. The Laravel HTTP client is a thin wrapper around Guzzle, so it accepts the same proxy option. Call Http::withOptions(["proxy" => "http://USER:PASS@gw.knoxproxy.com:7000"])->get($url) in a controller or job, and the request routes through KnoxProxy exactly like a raw Guzzle or cURL call would, with the usual Laravel response helpers still available.
Leave CURLOPT_SSL_VERIFYPEER set to true, as shown in the working example above; disabling it to work around a proxy is a certificate error waiting to happen, not a real fix. If you see certificate errors through KnoxProxy, update your local CA bundle instead, since an outdated bundle is the usual cause, not the proxy connection itself.
Rotating residential proxies -- 2 minutes setup, instant activation, 14-day money-back guarantee.