xref: /curl/docs/libcurl/opts/CURLOPT_NOPROXY.md (revision c4ab3337)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_NOPROXY
5Section: 3
6Source: libcurl
7Protocol:
8  - All
9See-also:
10  - CURLOPT_PROXY (3)
11  - CURLOPT_PROXYAUTH (3)
12  - CURLOPT_PROXYTYPE (3)
13Added-in: 7.19.4
14---
15
16# NAME
17
18CURLOPT_NOPROXY - disable proxy use for specific hosts
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NOPROXY, char *noproxy);
26~~~
27
28# DESCRIPTION
29
30Pass a pointer to a null-terminated string. The string consists of a comma
31separated list of hostnames that do not require a proxy to get reached, even
32if one is specified. The only wildcard available is a single * character,
33which matches all hosts, and effectively disables the proxy. Each name in this
34list is matched as either a domain which contains the hostname, or the
35hostname itself. For example, "ample.com" would match ample.com, ample.com:80,
36and www.ample.com, but not www.example.com or ample.com.org.
37
38Setting the *noproxy* string to "" (an empty string) explicitly enables the
39proxy for all hostnames, even if there is an environment variable set for it.
40
41Enter IPv6 numerical addresses in the list of hostnames without enclosing
42brackets:
43
44    "example.com,::1,localhost"
45
46Since 7.86.0, IP addresses specified to this option can be provided using CIDR
47notation: an appended slash and number specifies the number of "network bits"
48out of the address to use in the comparison. For example "192.168.0.0/16"
49would match all addresses starting with "192.168".
50
51The application does not have to keep the string around after setting this
52option.
53
54Using this option multiple times makes the last set string override the
55previous ones. Set it to NULL to disable its use again.
56
57# Environment variables
58
59If there is an environment variable called **no_proxy** (or **NO_PROXY**),
60it is used if the CURLOPT_NOPROXY(3) option is not set. It works exactly
61the same way.
62
63# DEFAULT
64
65NULL
66
67# %PROTOCOLS%
68
69# EXAMPLE
70
71~~~c
72int main(void)
73{
74  CURL *curl = curl_easy_init();
75  if(curl) {
76    /* accept various URLs */
77    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
78    /* use this proxy */
79    curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80");
80    /* ... but make sure this host name is not proxied */
81    curl_easy_setopt(curl, CURLOPT_NOPROXY, "www.example.com");
82    curl_easy_perform(curl);
83  }
84}
85~~~
86
87# %AVAILABILITY%
88
89# RETURN VALUE
90
91Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or
92CURLE_OUT_OF_MEMORY if there was insufficient heap space.
93