code

curl이 프록시를 무시하도록하려면 어떻게해야합니까?

codestyles 2020. 9. 4. 07:28
반응형

curl이 프록시를 무시하도록하려면 어떻게해야합니까?


curl이 프록시를 무시하도록하려면 어떻게해야합니까? $ NO_PROXY 설정이 작동하지 않는 것 같습니다.


curl이 환경 변수에서 프록시 주소를 읽고 http_proxy변수가 값을 유지해야 한다고 가정 합니다. 그런 다음 bash와 같은 셸 export http_proxy='';에서 명령 (또는 셸 스크립트)이 일시적으로 값을 변경하기 전에.

( ENVIRONMENT표제 아래에있는 모든 변수에 대해서는 curl의 설명서를 참조하십시오 .)


당신의 curl버전이 적어도 버전 이라면 플래그를 7.19.4사용할 수 있습니다 --noproxy.

curl --noproxy "*" http://www.stackoverflow.com

로부터 수동 .


http_proxy 및 https_proxy 환경 변수를 설정했기 때문에 동일한 문제가 발생했습니다. 하지만 가끔 다른 네트워크에 연결하여 일시적으로 프록시를 우회해야합니다. 이를 수행하는 가장 쉬운 방법 (환경 변수를 변경하지 않고)은 다음과 같습니다.

curl --noproxy '*' stackoverflow.com

매뉴얼에서 : "유일한 와일드 카드는 모든 호스트와 일치하고 프록시를 효과적으로 비활성화하는 단일 * 문자입니다."

* 문자는 쉘에 의해 잘못 확장되지 않도록 인용됩니다.


잘 작동합니다. 프록시 문자열을 ""로 설정합니다.

curl -x "" http://www.stackoverflow.com

긴 샷이지만 man 페이지에 따라 프록시 설정을 무시해야하는 ""(빈 문자열)로 프록시를 설정해보십시오.


먼저 현재 프록시 설정을

env | sort | less

(같은 것이어야 함 http_proxy=http://wpad.local.machine.location:port number)

그런 다음 설정을 시도했습니다

export http_proxy=";" 

이 오류 메시지를 제공했습니다.

curl: (5) Couldn't resolve proxy ';'

시도

export http_proxy="" && curl http://servername:portnumber/destinationpath/ -d 55

그리고 작동했습니다!

추신! http-proxy를 원래 설정으로 되 돌리는 것을 잊지 마십시오.

export http_proxy=http://wpad.local.machine.location:port number

나는이 http_proxyhttps_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"
}

.curlrc에 프록시 기본 설정 추가

proxy = 1.2.3.4
noproxy = .dev,localhost,127.0.0.1

이렇게하면 모든 개발 도메인과 로컬 시스템 요청이 프록시를 무시합니다.


$no_proxyenv 변수 (소문자)를 사용해야합니다 . 예제 https://wiki.archlinux.org/index.php/proxy_settings참조 하십시오 .

또한 오래 전에 curl에 버그가있었습니다. http://sourceforge.net/p/curl/bugs/185/ , 아마도이 버그를 포함하는 고대 curl 버전을 사용하고있을 것입니다.


제 경우 (macos, curl 7.54.0), 아래 프록시 설정이 있습니다.~/.bash_profile

$ env |grep -i proxy |cut -d = -f1|sort
FTP_PROXY
HTTPS_PROXY
HTTP_PROXY
NO_PROXY
PROXY
ftp_proxy
http_proxy
https_proxy
no_proxy

With unknown reason, this version of curl can't work with environment variables NO_PRXY and no_proxy properly, then I unset the proxy environment variables one by one, until to both HTTPS_PROXY and https_proxy.

unset HTTPS_PROXY
unset https_proxy

it starts working and can connect to internal urls

So I would recommend to unset all proxy variables if you have in your environment as temporary solution.

unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY

Lame answer but: Remember to make sure no proxy is set in a ~/.curlrc file (...).


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.

참고URL : https://stackoverflow.com/questions/800805/how-do-i-make-curl-ignore-the-proxy

반응형