Before you start
Nefo offers residential proxies across 227 countries over HTTP, HTTPS, and SOCKS5 with username/password auth. Generate credentials for free in the dashboard proxy generator; only routed traffic consumes your prepaid bandwidth (from 5 GB for $4.50, non-expiring on flexible plans).
PHP's cURL extension covers both HTTP and SOCKS5, and Guzzle can wrap the same settings if you prefer a higher-level client.
- PHP 8.0+ with the curl extension enabled
- A Nefo account with prepaid bandwidth
- A username/password from /dashboard/generator
- Your chosen protocol and port
- Your target country token
PHP cURL proxy example
Set proxy options on a cURL handle:
For SOCKS5, add curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME) and use port 11000, which resolves DNS through the proxy. Change the country token to target any of 227 countries.
<?php
$ch = curl_init('https://api.ipify.org');
curl_setopt($ch, CURLOPT_PROXY, 'gw.nefo.net:9000');
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'USERNAME-country-us:PASSWORD');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);PHP rotating vs sticky proxy sessions
Rotating sessions give a new residential IP per request: HTTP port 9000 or SOCKS5 port 11000. Good for spreading requests across many exits.
Sticky sessions hold one IP from 1 minute up to 24 hours: HTTP port 10000 or SOCKS5 port 12000. Set CURLOPT_PROXYUSERPWD to a token like USERNAME-country-us-session-cron1-lifetime-30 to keep one IP across a job.
Geo-targeting in the PHP proxy username
Targeting is set through username tokens: country across 227 countries, US state and city, or ASN/ISP within a country. Only the username in CURLOPT_PROXYUSERPWD changes between regions.
Collect data lawfully, respect each site's terms of service, and stay within applicable law and reasonable request rates.
Frequently asked questions
Set CURLOPT_PROXYUSERPWD to 'USERNAME-country-us:PASSWORD' and keep the host and port in CURLOPT_PROXY, for example gw.nefo.net:9000. Do not put the credentials in the host string.
Set CURLOPT_PROXYTYPE to CURLPROXY_SOCKS5_HOSTNAME and point CURLOPT_PROXY at port 11000 (rotating) or 12000 (sticky). The HOSTNAME variant resolves DNS on the proxy. See SOCKS5 proxies.
Use port 10000 with a session token such as USERNAME-country-us-session-cron1-lifetime-30 in CURLOPT_PROXYUSERPWD. The residential IP stays fixed for the lifetime you set, up to 24 hours.
Yes. Add country tokens, and for the US state and city tokens, to the username, plus ASN or ISP options within a country. Only the CURLOPT_PROXYUSERPWD string changes.
Yes. Guzzle can wrap the same cURL settings if you prefer a higher-level client. The host, port, username and password stay the same.
No. Generating credentials is free; only the traffic your requests route through the proxy consumes prepaid bandwidth.