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