CURLOPT_PROXY.3 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH CURLOPT_PROXY 3 "17 Jun 2014" libcurl libcurl
  26. .SH NAME
  27. CURLOPT_PROXY \- proxy to use
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY, char *proxy);
  32. .fi
  33. .SH DESCRIPTION
  34. Set the \fIproxy\fP to use for the upcoming request. The parameter should be a
  35. char * to a null-terminated string holding the host name or dotted numerical
  36. IP address. A numerical IPv6 address must be written within [brackets].
  37. To specify port number in this string, append :[port] to the end of the host
  38. name. The proxy's port number may optionally be specified with the separate
  39. option \fICURLOPT_PROXYPORT(3)\fP. If not specified, libcurl will default to
  40. using port 1080 for proxies.
  41. The proxy string may be prefixed with [scheme]:// to specify which kind of
  42. proxy is used.
  43. .RS
  44. .IP http://
  45. HTTP Proxy. Default when no scheme or proxy type is specified.
  46. .IP https://
  47. HTTPS Proxy. (Added in 7.52.0 for OpenSSL, GnuTLS and NSS. Since 7.87.0, it
  48. also works for BearSSL, mbedTLS, rustls, Schannel, Secure Transport and
  49. wolfSSL.)
  50. This will use HTTP/1 by default. Setting \fICURLOPT_PROXYTYPE(3)\fP to
  51. \fBCURLPROXY_HTTPS2\fP allows libcurl to negotiate using HTTP/2 with proxy.
  52. .IP socks4://
  53. SOCKS4 Proxy.
  54. .IP socks4a://
  55. SOCKS4a Proxy. Proxy resolves URL hostname.
  56. .IP socks5://
  57. SOCKS5 Proxy.
  58. .IP socks5h://
  59. SOCKS5 Proxy. Proxy resolves URL hostname.
  60. .RE
  61. Without a scheme prefix, \fICURLOPT_PROXYTYPE(3)\fP can be used to specify
  62. which kind of proxy the string identifies.
  63. When you tell the library to use an HTTP proxy, libcurl will transparently
  64. convert operations to HTTP even if you specify an FTP URL etc. This may have
  65. an impact on what other features of the library you can use, such as
  66. \fICURLOPT_QUOTE(3)\fP and similar FTP specifics that do not work unless you
  67. tunnel through the HTTP proxy. Such tunneling is activated with
  68. \fICURLOPT_HTTPPROXYTUNNEL(3)\fP.
  69. Setting the proxy string to "" (an empty string) will explicitly disable the
  70. use of a proxy, even if there is an environment variable set for it.
  71. A proxy host string can also include protocol scheme (http://) and embedded
  72. user + password.
  73. Unix domain sockets are supported for socks proxies since 7.84.0. Set
  74. localhost for the host part. e.g. socks5h://localhost/path/to/socket.sock
  75. The application does not have to keep the string around after setting this
  76. option.
  77. When a proxy is used, the active FTP mode as set with \fICUROPT_FTPPORT(3)\fP,
  78. cannot be used.
  79. .SH "Environment variables"
  80. libcurl respects the proxy environment variables named \fBhttp_proxy\fP,
  81. \fBftp_proxy\fP, \fBsftp_proxy\fP etc. If set, libcurl will use the specified
  82. proxy for that URL scheme. So for a "FTP://" URL, the \fBftp_proxy\fP is
  83. considered. \fBall_proxy\fP is used if no protocol specific proxy was set.
  84. If \fBno_proxy\fP (or \fBNO_PROXY\fP) is set, it is the exact equivalent of
  85. setting the \fICURLOPT_NOPROXY(3)\fP option.
  86. The \fICURLOPT_PROXY(3)\fP and \fICURLOPT_NOPROXY(3)\fP options override
  87. environment variables.
  88. .SH DEFAULT
  89. Default is NULL, meaning no proxy is used.
  90. When you set a host name to use, do not assume that there's any particular
  91. single port number used widely for proxies. Specify it!
  92. .SH PROTOCOLS
  93. All except file://. Note that some protocols do not work well over proxy.
  94. .SH EXAMPLE
  95. .nf
  96. CURL *curl = curl_easy_init();
  97. if(curl) {
  98. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/file.txt");
  99. curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80");
  100. curl_easy_perform(curl);
  101. }
  102. .fi
  103. .SH AVAILABILITY
  104. Since 7.14.1 the proxy environment variable names can include the protocol
  105. scheme.
  106. Since 7.21.7 the proxy string supports the socks protocols as "schemes".
  107. Since 7.50.2, unsupported schemes in proxy strings cause libcurl to return
  108. error.
  109. curl built to use NSS cannot connect to an HTTPS server over a unix domain
  110. socket.
  111. .SH RETURN VALUE
  112. Returns CURLE_OK if proxies are supported, CURLE_UNKNOWN_OPTION if not, or
  113. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  114. .SH "SEE ALSO"
  115. .BR CURLOPT_PROXYPORT "(3), " CURLOPT_HTTPPROXYTUNNEL "(3), "
  116. .BR CURLOPT_PROXYTYPE "(3)"