How do I make curl ignore the proxy?

后端 未结 12 1497
别跟我提以往
别跟我提以往 2021-01-30 03:01

How do I make curl ignore the proxy? Setting $NO_PROXY doesn\'t seem to work for me.

相关标签:
12条回答
  • 2021-01-30 03:26

    First, I listed the current proxy setting with

    env | sort | less
    

    (should be something like 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

    export http_proxy=http://wpad.local.machine.location:port number
    
    0 讨论(0)
  • 2021-01-30 03:27

    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.

    (See curl's manual for all the variables it looks at, under the ENVIRONMENT heading.)

    0 讨论(0)
  • 2021-01-30 03:29

    Long shot but try setting the proxy to "" (empty string) that should override any proxy settings according to the man page.

    0 讨论(0)
  • 2021-01-30 03:33

    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.

    0 讨论(0)
  • 2021-01-30 03:36

    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:

    curl --noproxy '*' stackoverflow.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.

    0 讨论(0)
  • 2021-01-30 03:38

    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.

    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"
    }
    
    0 讨论(0)
提交回复
热议问题