1CURLOPT_PROXY(3) curl_easy_setopt options CURLOPT_PROXY(3)
2
3
4
6 CURLOPT_PROXY - proxy to use
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY, char *proxy);
12
14 Set the proxy to use for the upcoming request. The parameter should be
15 a char * to a null-terminated string holding the host name or dotted
16 numerical IP address. A numerical IPv6 address must be written within
17 [brackets].
18
19 To specify port number in this string, append :[port] to the end of the
20 host name. The proxy's port number may optionally be specified with the
21 separate option CURLOPT_PROXYPORT(3). If not specified, libcurl will
22 default to using port 1080 for proxies.
23
24 The proxy string may be prefixed with [scheme]:// to specify which kind
25 of proxy is used.
26
27
28 http://
29 HTTP Proxy. Default when no scheme or proxy type is spec‐
30 ified.
31
32 https://
33 HTTPS Proxy. (Added in 7.52.0 for OpenSSL, GnuTLS and
34 NSS)
35
36 socks4://
37 SOCKS4 Proxy.
38
39 socks4a://
40 SOCKS4a Proxy. Proxy resolves URL hostname.
41
42 socks5://
43 SOCKS5 Proxy.
44
45 socks5h://
46 SOCKS5 Proxy. Proxy resolves URL hostname.
47
48 Without a scheme prefix, CURLOPT_PROXYTYPE(3) can be used to specify
49 which kind of proxy the string identifies.
50
51 When you tell the library to use an HTTP proxy, libcurl will transpar‐
52 ently convert operations to HTTP even if you specify an FTP URL etc.
53 This may have an impact on what other features of the library you can
54 use, such as CURLOPT_QUOTE(3) and similar FTP specifics that don't work
55 unless you tunnel through the HTTP proxy. Such tunneling is activated
56 with CURLOPT_HTTPPROXYTUNNEL(3).
57
58 Setting the proxy string to "" (an empty string) will explicitly dis‐
59 able the use of a proxy, even if there is an environment variable set
60 for it.
61
62 A proxy host string can also include protocol scheme (http://) and em‐
63 bedded user + password.
64
65 The application does not have to keep the string around after setting
66 this option.
67
69 libcurl respects the proxy environment variables named http_proxy,
70 ftp_proxy, sftp_proxy etc. If set, libcurl will use the specified proxy
71 for that URL scheme. So for a "FTP://" URL, the ftp_proxy is consid‐
72 ered. all_proxy is used if no protocol specific proxy was set.
73
74 If no_proxy (or NO_PROXY) is set, it is the exact equivalent of setting
75 the CURLOPT_NOPROXY(3) option.
76
77 The CURLOPT_PROXY(3) and CURLOPT_NOPROXY(3) options override environ‐
78 ment variables.
79
81 Default is NULL, meaning no proxy is used.
82
83 When you set a host name to use, do not assume that there's any partic‐
84 ular single port number used widely for proxies. Specify it!
85
87 All except file://. Note that some protocols don't do very well over
88 proxy.
89
91 CURL *curl = curl_easy_init();
92 if(curl) {
93 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/file.txt");
94 curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80");
95 curl_easy_perform(curl);
96 }
97
99 Since 7.14.1 the proxy environment variable names can include the pro‐
100 tocol scheme.
101
102 Since 7.21.7 the proxy string supports the socks protocols as
103 "schemes".
104
105 Since 7.50.2, unsupported schemes in proxy strings cause libcurl to re‐
106 turn error.
107
109 Returns CURLE_OK if proxies are supported, CURLE_UNKNOWN_OPTION if not,
110 or CURLE_OUT_OF_MEMORY if there was insufficient heap space.
111
113 CURLOPT_PROXYPORT(3), CURLOPT_HTTPPROXYTUNNEL(3), CURLOPT_PROXYTYPE(3)
114
115
116
117libcurl 7.79.1 September 08, 2021 CURLOPT_PROXY(3)