CURLOPT_NOPROXY.md (2592B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_NOPROXY 5 Section: 3 6 Source: libcurl 7 Protocol: 8 - All 9 See-also: 10 - CURLOPT_PROXY (3) 11 - CURLOPT_PROXYAUTH (3) 12 - CURLOPT_PROXYTYPE (3) 13 Added-in: 7.19.4 14 --- 15 16 # NAME 17 18 CURLOPT_NOPROXY - disable proxy use for specific hosts 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NOPROXY, char *noproxy); 26 ~~~ 27 28 # DESCRIPTION 29 30 Pass a pointer to a null-terminated string. The string consists of a comma 31 separated list of hostnames that do not require a proxy to get reached, even 32 if one is specified. The only wildcard available is a single * character, 33 which matches all hosts, and effectively disables the proxy. Each name in this 34 list is matched as either a domain which contains the hostname, or the 35 hostname itself. For example, "ample.com" would match ample.com, ample.com:80, 36 and www.ample.com, but not www.example.com or ample.com.org. 37 38 Setting the *noproxy* string to "" (an empty string) explicitly enables the 39 proxy for all hostnames, even if there is an environment variable set for it. 40 41 Enter IPv6 numerical addresses in the list of hostnames without enclosing 42 brackets: 43 44 "example.com,::1,localhost" 45 46 Since 7.86.0, IP addresses specified to this option can be provided using CIDR 47 notation: an appended slash and number specifies the number of "network bits" 48 out of the address to use in the comparison. For example "192.168.0.0/16" 49 would match all addresses starting with "192.168". 50 51 The application does not have to keep the string around after setting this 52 option. 53 54 Using this option multiple times makes the last set string override the 55 previous ones. Set it to NULL to disable its use again. 56 57 # Environment variables 58 59 If there is an environment variable called **no_proxy** (or **NO_PROXY**), 60 it is used if the CURLOPT_NOPROXY(3) option is not set. It works exactly 61 the same way. 62 63 # DEFAULT 64 65 NULL 66 67 # %PROTOCOLS% 68 69 # EXAMPLE 70 71 ~~~c 72 int 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 91 curl_easy_setopt(3) returns a CURLcode indicating success or error. 92 93 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 94 libcurl-errors(3).