1CURLOPT_PROXY(3)           curl_easy_setopt options           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)
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  do  not
55       work  unless you tunnel through the HTTP proxy. Such tunneling is acti‐
56       vated 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       Unix  domain  sockets are supported for socks proxies since 7.84.0. Set
66       localhost    for    the    host     part.     e.g.     socks5h://local‐
67       host/path/to/socket.sock
68
69       The  application  does not have to keep the string around after setting
70       this option.
71
72       When a proxy is used, the active  FTP  mode  as  set  with  CUROPT_FTP‐
73       PORT(3), cannot be used.
74

Environment variables

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

DEFAULT

88       Default is NULL, meaning no proxy is used.
89
90       When you set a host name to use, do not assume that there's any partic‐
91       ular single port number used widely for proxies. Specify it!
92

PROTOCOLS

94       All  except  file://.  Note  that  some protocols do not work well over
95       proxy.
96

EXAMPLE

98       CURL *curl = curl_easy_init();
99       if(curl) {
100         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/file.txt");
101         curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80");
102         curl_easy_perform(curl);
103       }
104

AVAILABILITY

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

RETURN VALUE

119       Returns CURLE_OK if proxies are supported, CURLE_UNKNOWN_OPTION if not,
120       or CURLE_OUT_OF_MEMORY if there was insufficient heap space.
121

SEE ALSO

123       CURLOPT_PROXYPORT(3), CURLOPT_HTTPPROXYTUNNEL(3), CURLOPT_PROXYTYPE(3)
124
125
126
127libcurl 8.0.1                   March 10, 2023                CURLOPT_PROXY(3)
Impressum