CURLOPT_CONNECT_TO changes the host and port libcurl connects to for a matching destination. It does not make the alternate endpoint speak HTTP CONNECT or SOCKS.

The original hostname still supplies the application-protocol and TLS identity. This is useful when deliberately reaching another server instance of the same service. An arbitrary proxy listener instead expects its proxy handshake, not the application's raw bytes.

Combining the mapping with an HTTP proxy

Configure the HTTP proxy separately. A credential-free HTTP route to a public service may use an endpoint from the HTTP proxy list when that intermediary is permitted; no existing proxy account should be sent to the candidate. libcurl documents that a differing connect-to mapping can then switch the request into tunnel mode: the proxy opens the mapped destination connection. The mapping selects what is reached through the proxy; it has not replaced the proxy configuration.

Keep three values distinct: the intended service name, the alternate connection endpoint and the proxy endpoint. Select each option for its actual role and keep normal TLS name verification for the service.

If the proxy port itself refuses connections, another option pointing at that same absent listener cannot fix the first hop. Resolve that listener or path failure before changing destination mapping.

Artiglyn mynjee