CURLOPT_PROXY.3 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. .\" generated by cd2nroff 0.1 from CURLOPT_PROXY.md
  2. .TH CURLOPT_PROXY 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_PROXY \- proxy to use
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY, char *proxy);
  9. .fi
  10. .SH DESCRIPTION
  11. Set the \fIproxy\fP to use for transfers with this easy handle. The parameter
  12. should be a char * to a null\-terminated string holding the hostname or dotted
  13. numerical IP address. A numerical IPv6 address must be written within
  14. [brackets].
  15. To specify port number in this string, append :[port] to the end of the host
  16. name. The proxy\(aqs port number may optionally (but discouraged) be specified
  17. with the separate option \fICURLOPT_PROXYPORT(3)\fP. If not specified, libcurl
  18. defaults to using port 1080 for proxies.
  19. The proxy string may be prefixed with [scheme]:// to specify which kind of
  20. proxy is used.
  21. .IP http://
  22. HTTP Proxy. Default when no scheme or proxy type is specified.
  23. .IP https://
  24. HTTPS Proxy. (Added in 7.52.0 for OpenSSL and GnuTLS Since 7.87.0, it
  25. also works for BearSSL, mbedTLS, rustls, Schannel, Secure Transport and
  26. wolfSSL.)
  27. This uses HTTP/1 by default. Setting \fICURLOPT_PROXYTYPE(3)\fP to
  28. \fBCURLPROXY_HTTPS2\fP allows libcurl to negotiate using HTTP/2 with proxy.
  29. .IP socks4://
  30. SOCKS4 Proxy.
  31. .IP socks4a://
  32. SOCKS4a Proxy. Proxy resolves URL hostname.
  33. .IP socks5://
  34. SOCKS5 Proxy.
  35. .IP socks5h://
  36. SOCKS5 Proxy. Proxy resolves URL hostname.
  37. .PP
  38. Without a scheme prefix, \fICURLOPT_PROXYTYPE(3)\fP can be used to specify which
  39. kind of proxy the string identifies.
  40. When you tell the library to use an HTTP proxy, libcurl transparently converts
  41. operations to HTTP even if you specify an FTP URL etc. This may have an impact
  42. on what other features of the library you can use, such as \fICURLOPT_QUOTE(3)\fP
  43. and similar FTP specifics that do not work unless you tunnel through the HTTP
  44. proxy. Such tunneling is activated with \fICURLOPT_HTTPPROXYTUNNEL(3)\fP.
  45. Setting the proxy string to "" (an empty string) explicitly disables the use
  46. of a proxy, even if there is an environment variable set for it.
  47. A proxy host string can also include protocol scheme (http://) and embedded
  48. user + password.
  49. Unix domain sockets are supported for socks proxies since 7.84.0. Set
  50. localhost for the host part. e.g. socks5h://localhost/path/to/socket.sock
  51. When you set a hostname to use, do not assume that there is any particular
  52. single port number used widely for proxies. Specify it.
  53. When a proxy is used, the active FTP mode as set with \fICUROPT_FTPPORT(3)\fP,
  54. cannot be used.
  55. .SH Environment variables
  56. libcurl respects the proxy environment variables named \fBhttp_proxy\fP,
  57. \fBftp_proxy\fP, \fBsftp_proxy\fP etc. If set, libcurl uses the specified proxy
  58. for that URL scheme. For an "FTP://" URL, the \fBftp_proxy\fP is
  59. considered. \fBall_proxy\fP is used if no protocol specific proxy was set.
  60. If \fBno_proxy\fP (or \fBNO_PROXY\fP) is set, it is the exact equivalent of
  61. setting the \fICURLOPT_NOPROXY(3)\fP option.
  62. The \fICURLOPT_PROXY(3)\fP and \fICURLOPT_NOPROXY(3)\fP options override environment
  63. variables.
  64. .SH DEFAULT
  65. NULL
  66. .SH PROTOCOLS
  67. This functionality affects all supported protocols
  68. .SH EXAMPLE
  69. .nf
  70. int main(void)
  71. {
  72. CURL *curl = curl_easy_init();
  73. if(curl) {
  74. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/file.txt");
  75. curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80");
  76. curl_easy_perform(curl);
  77. }
  78. }
  79. .fi
  80. .SH HISTORY
  81. Since 7.14.1 the proxy environment variable names can include the protocol
  82. scheme.
  83. Since 7.21.7 the proxy string supports the socks protocols as "schemes".
  84. Since 7.50.2, unsupported schemes in proxy strings cause libcurl to return
  85. error.
  86. .SH AVAILABILITY
  87. Added in curl 7.1
  88. .SH RETURN VALUE
  89. Returns CURLE_OK if proxies are supported, CURLE_UNKNOWN_OPTION if not, or
  90. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  91. .SH SEE ALSO
  92. .BR CURLOPT_HTTPPROXYTUNNEL (3),
  93. .BR CURLOPT_PRE_PROXY (3),
  94. .BR CURLOPT_PROXYPORT (3),
  95. .BR CURLOPT_PROXYTYPE (3)