1CURLOPT_PROXY(3)                    libcurl                   CURLOPT_PROXY(3)
2
3
4

NAME

6       CURLOPT_PROXY - proxy to use
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY, char *proxy);
12

DESCRIPTION

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. Since 7.87.0, it also works  for  BearSSL,  mbedTLS,
35                     rustls, Schannel, Secure Transport and wolfSSL.)
36
37                     This  will  use HTTP/1 by default. Setting CURLOPT_PROXY‐
38                     TYPE(3) to CURLPROXY_HTTPS2 allows libcurl  to  negotiate
39                     using HTTP/2 with proxy.
40
41              socks4://
42                     SOCKS4 Proxy.
43
44              socks4a://
45                     SOCKS4a Proxy. Proxy resolves URL hostname.
46
47              socks5://
48                     SOCKS5 Proxy.
49
50              socks5h://
51                     SOCKS5 Proxy. Proxy resolves URL hostname.
52
53       Without  a  scheme  prefix, CURLOPT_PROXYTYPE(3) can be used to specify
54       which kind of proxy the string identifies.
55
56       When you tell the library to use an HTTP proxy, libcurl will  transpar‐
57       ently  convert  operations  to HTTP even if you specify an FTP URL etc.
58       This may have an impact on what other features of the library  you  can
59       use,  such  as  CURLOPT_QUOTE(3)  and similar FTP specifics that do not
60       work unless you tunnel through the HTTP proxy. Such tunneling is  acti‐
61       vated with CURLOPT_HTTPPROXYTUNNEL(3).
62
63       Setting  the  proxy string to "" (an empty string) will explicitly dis‐
64       able the use of a proxy, even if there is an environment  variable  set
65       for it.
66
67       A  proxy host string can also include protocol scheme (http://) and em‐
68       bedded user + password.
69
70       Unix domain sockets are supported for socks proxies since  7.84.0.  Set
71       localhost     for     the     host    part.    e.g.    socks5h://local‐
72       host/path/to/socket.sock
73
74       The application does not have to keep the string around  after  setting
75       this option.
76
77       When  a  proxy  is  used,  the  active FTP mode as set with CUROPT_FTP‐
78       PORT(3), cannot be used.
79

Environment variables

81       libcurl respects the  proxy  environment  variables  named  http_proxy,
82       ftp_proxy, sftp_proxy etc. If set, libcurl will use the specified proxy
83       for that URL scheme. So for a "FTP://" URL, the  ftp_proxy  is  consid‐
84       ered. all_proxy is used if no protocol specific proxy was set.
85
86       If no_proxy (or NO_PROXY) is set, it is the exact equivalent of setting
87       the CURLOPT_NOPROXY(3) option.
88
89       The CURLOPT_PROXY(3) and CURLOPT_NOPROXY(3) options  override  environ‐
90       ment variables.
91

DEFAULT

93       Default is NULL, meaning no proxy is used.
94
95       When you set a host name to use, do not assume that there's any partic‐
96       ular single port number used widely for proxies. Specify it!
97

PROTOCOLS

99       All except file://. Note that some protocols  do  not  work  well  over
100       proxy.
101

EXAMPLE

103       CURL *curl = curl_easy_init();
104       if(curl) {
105         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/file.txt");
106         curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80");
107         curl_easy_perform(curl);
108       }
109

AVAILABILITY

111       Since  7.14.1 the proxy environment variable names can include the pro‐
112       tocol scheme.
113
114       Since  7.21.7  the  proxy  string  supports  the  socks  protocols   as
115       "schemes".
116
117       Since 7.50.2, unsupported schemes in proxy strings cause libcurl to re‐
118       turn error.
119
120       curl built to use NSS cannot connect to an HTTPS server over a unix do‐
121       main socket.
122

RETURN VALUE

124       Returns CURLE_OK if proxies are supported, CURLE_UNKNOWN_OPTION if not,
125       or CURLE_OUT_OF_MEMORY if there was insufficient heap space.
126

SEE ALSO

128       CURLOPT_PROXYPORT(3), CURLOPT_HTTPPROXYTUNNEL(3), CURLOPT_PROXYTYPE(3)
129
130
131
132ibcurl 8.2.1                    April 27, 2023                CURLOPT_PROXY(3)
Impressum