A machine with several local addresses may need one of them for its connection to a forward proxy. cURL can make both choices explicitly:

curl_setopt_array($handle, [
    CURLOPT_URL => 'https://example.com/',
    CURLOPT_INTERFACE => '192.0.2.20',
    CURLOPT_PROXY => 'http://proxy.example:8080',
]);

This is an illustrative configuration for an existing cURL handle. Replace 192.0.2.20 with a source address actually available on the machine running PHP. For an allowed public request without a proxy account, the HTTP proxy list can supply the remote listener for the proxy value.

CURLOPT_INTERFACE selects the local side of the outgoing connection. CURLOPT_PROXY selects the intermediary that carries the request onward. Choosing a local source does not turn that machine into a remote proxy or give it an arbitrary public IP.

For this path, the local selection affects the connection toward the proxy. The website generally sees the proxy’s onward source address. NAT between either pair of peers can further translate the address each receiver sees.

If interface selection is omitted, libcurl lets the TCP stack choose a suitable source. That choice follows the machine’s networking configuration; it is not a universal rule that the first address in a configuration file wins.

libcurl accepts interface names on supported platforms, but its documentation excludes Windows interface-name selection for this option. Using a hostname can also trigger a blocking lookup. A known local address is a clearer input when that is the choice the application intends.

Ũhoro ũhĩtĩte