How do I make curl ignore the proxy? Setting $NO_PROXY doesn't seem to work for me.
如何使curl忽略代理?设置$ NO_PROXY对我来说似乎不起作用。
11 个解决方案
#1
I assume curl is reading the proxy address from the environment variable http_proxy
and that the variable should keep its value. Then in a shell like bash, export http_proxy='';
before a command (or in a shell script) would temporarily change its value.
我假设curl正在从环境变量http_proxy读取代理地址,并且该变量应保持其值。然后在像bash这样的shell中,导出http_proxy ='';在命令(或shell脚本)之前暂时更改其值。
(See curl's manual for all the variables it looks at, under the ENVIRONMENT
heading.)
(请参阅curl的手册,了解它在环境标题下查看的所有变量。)
#2
#3
I ran into the same problem because I set the http_proxy and https_proxy environment variables. But occasionally, I connect to a different network and need to bypass the proxy temporarily. The easiest way to do this (without changing the environment variables) is:
我遇到了同样的问题,因为我设置了http_proxy和https_proxy环境变量。但偶尔,我连接到不同的网络,需要暂时绕过代理。最简单的方法(不更改环境变量)是:
curl --noproxy '*' *.com
From the manual: "The only wildcard is a single * character, which matches all hosts, and effectively disables the proxy."
从手册:“唯一的通配符是单个*字符,它匹配所有主机,并有效地禁用代理。”
The * character is quoted so that it is not erroneously expanded by the shell.
引用*字符,以便shell不会错误地扩展它。
#4
Long shot but try setting the proxy to "" (empty string) that should override any proxy settings according to the man page.
远程但尝试将代理设置为“”(空字符串),应根据手册页覆盖任何代理设置。
#5
First, I listed the current proxy setting with
首先,我列出了当前的代理设置
env | sort | less
(should be something like http_proxy=http://wpad.local.machine.location:port number
)
(应该像http_proxy = http://wpad.local.machine.location:port number)
Then I tried setting
然后我尝试了设置
export http_proxy=";"
which gave this error message:
出现此错误消息:
curl: (5) Couldn't resolve proxy ';'
Tried
export http_proxy="" && curl http://servername:portnumber/destinationpath/ -d 55
and it worked!
它工作了!
PS! Remember to set http-proxy back to its original settings with
PS!请记住将http-proxy设置回其原始设置
export http_proxy=http://wpad.local.machine.location:port number
#6
I have http_proxy
and https_proxy
are defined. I don't want to unset and set again those environments but --noproxy '*'
works perfectly for me.
我已经定义了http_proxy和https_proxy。我不想取消设置并再次设置这些环境,但是--noproxy'*'对我来说非常适合。
curl --noproxy '*' -XGET 172.17.0.2:9200
{
"status" : 200,
"name" : "Medusa",
"cluster_name" : "elasticsearch",
"version" : {
"number" : "1.5.0",
"build_hash" : "544816042d40151d3ce4ba4f95399d7860dc2e92",
"build_timestamp" : "2015-03-23T14:30:58Z",
"build_snapshot" : false,
"lucene_version" : "4.10.4"
},
"tagline" : "You Know, for Search"
}
#7
You should use $no_proxy
env variable (lower-case). Please consult https://wiki.archlinux.org/index.php/proxy_settings for examples.
你应该使用$ no_proxy env变量(小写)。有关示例,请参阅https://wiki.archlinux.org/index.php/proxy_settings。
Also, there was a bug at curl long time ago http://sourceforge.net/p/curl/bugs/185/ , maybe you are using an ancient curl version that includes this bug.
此外,很久以前在curl上有一个错误http://sourceforge.net/p/curl/bugs/185/,也许你正在使用包含这个bug的古老卷曲版本。
#8
Add your proxy preferences into .curlrc
将您的代理首选项添加到.curlrc中
proxy = 1.2.3.4
noproxy = .dev,localhost,127.0.0.1
This make all dev domains and local machine request ignore the proxy.
这使得所有开发域和本地机器请求都忽略了代理。
#9
Lame answer but: Remember to make sure no proxy is set in a ~/.curlrc
file (...).
Lame回答但是:请记住确保在〜/ .curlrc文件(...)中没有设置代理。
#10
This works just fine, set the proxy string to ""
这很好用,将代理字符串设置为“”
curl -x "" http://www.*.com
#11
My curl was not ignoring the proxy on Ubuntu 12.04 until I set the "no_proxy" (lowercase) environment variable. The --noproxy option was not available.
在我设置“no_proxy”(小写)环境变量之前,我的卷曲并没有忽略Ubuntu 12.04上的代理。 --noproxy选项不可用。
#1
I assume curl is reading the proxy address from the environment variable http_proxy
and that the variable should keep its value. Then in a shell like bash, export http_proxy='';
before a command (or in a shell script) would temporarily change its value.
我假设curl正在从环境变量http_proxy读取代理地址,并且该变量应保持其值。然后在像bash这样的shell中,导出http_proxy ='';在命令(或shell脚本)之前暂时更改其值。
(See curl's manual for all the variables it looks at, under the ENVIRONMENT
heading.)
(请参阅curl的手册,了解它在环境标题下查看的所有变量。)
#2
If your curl
is at least version 7.19.4
, you could just use the --noproxy
flag.
如果你的curl至少是版本7.19.4,你可以使用--noproxy标志。
curl --noproxy "*" http://www.*.com
From the manual.
从手册。
#3
I ran into the same problem because I set the http_proxy and https_proxy environment variables. But occasionally, I connect to a different network and need to bypass the proxy temporarily. The easiest way to do this (without changing the environment variables) is:
我遇到了同样的问题,因为我设置了http_proxy和https_proxy环境变量。但偶尔,我连接到不同的网络,需要暂时绕过代理。最简单的方法(不更改环境变量)是:
curl --noproxy '*' *.com
From the manual: "The only wildcard is a single * character, which matches all hosts, and effectively disables the proxy."
从手册:“唯一的通配符是单个*字符,它匹配所有主机,并有效地禁用代理。”
The * character is quoted so that it is not erroneously expanded by the shell.
引用*字符,以便shell不会错误地扩展它。
#4
Long shot but try setting the proxy to "" (empty string) that should override any proxy settings according to the man page.
远程但尝试将代理设置为“”(空字符串),应根据手册页覆盖任何代理设置。
#5
First, I listed the current proxy setting with
首先,我列出了当前的代理设置
env | sort | less
(should be something like http_proxy=http://wpad.local.machine.location:port number
)
(应该像http_proxy = http://wpad.local.machine.location:port number)
Then I tried setting
然后我尝试了设置
export http_proxy=";"
which gave this error message:
出现此错误消息:
curl: (5) Couldn't resolve proxy ';'
Tried
export http_proxy="" && curl http://servername:portnumber/destinationpath/ -d 55
and it worked!
它工作了!
PS! Remember to set http-proxy back to its original settings with
PS!请记住将http-proxy设置回其原始设置
export http_proxy=http://wpad.local.machine.location:port number
#6
I have http_proxy
and https_proxy
are defined. I don't want to unset and set again those environments but --noproxy '*'
works perfectly for me.
我已经定义了http_proxy和https_proxy。我不想取消设置并再次设置这些环境,但是--noproxy'*'对我来说非常适合。
curl --noproxy '*' -XGET 172.17.0.2:9200
{
"status" : 200,
"name" : "Medusa",
"cluster_name" : "elasticsearch",
"version" : {
"number" : "1.5.0",
"build_hash" : "544816042d40151d3ce4ba4f95399d7860dc2e92",
"build_timestamp" : "2015-03-23T14:30:58Z",
"build_snapshot" : false,
"lucene_version" : "4.10.4"
},
"tagline" : "You Know, for Search"
}
#7
You should use $no_proxy
env variable (lower-case). Please consult https://wiki.archlinux.org/index.php/proxy_settings for examples.
你应该使用$ no_proxy env变量(小写)。有关示例,请参阅https://wiki.archlinux.org/index.php/proxy_settings。
Also, there was a bug at curl long time ago http://sourceforge.net/p/curl/bugs/185/ , maybe you are using an ancient curl version that includes this bug.
此外,很久以前在curl上有一个错误http://sourceforge.net/p/curl/bugs/185/,也许你正在使用包含这个bug的古老卷曲版本。
#8
Add your proxy preferences into .curlrc
将您的代理首选项添加到.curlrc中
proxy = 1.2.3.4
noproxy = .dev,localhost,127.0.0.1
This make all dev domains and local machine request ignore the proxy.
这使得所有开发域和本地机器请求都忽略了代理。
#9
Lame answer but: Remember to make sure no proxy is set in a ~/.curlrc
file (...).
Lame回答但是:请记住确保在〜/ .curlrc文件(...)中没有设置代理。
#10
This works just fine, set the proxy string to ""
这很好用,将代理字符串设置为“”
curl -x "" http://www.*.com
#11
My curl was not ignoring the proxy on Ubuntu 12.04 until I set the "no_proxy" (lowercase) environment variable. The --noproxy option was not available.
在我设置“no_proxy”(小写)环境变量之前,我的卷曲并没有忽略Ubuntu 12.04上的代理。 --noproxy选项不可用。