How do I make curl ignore the proxy?

后端 未结 12 1496
别跟我提以往
别跟我提以往 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:11

    If your curl is at least version 7.19.4, you could just use the --noproxy flag.

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

    From the manual.

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

    This works just fine, set the proxy string to ""

    curl -x "" http://www.stackoverflow.com
    
    0 讨论(0)
  • 2021-01-30 03:15

    You should use $no_proxy env variable (lower-case). Please consult https://wiki.archlinux.org/index.php/proxy_settings for examples.

    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.

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

    Add your proxy preferences into .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.

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

    In my case (macos, curl 7.54.0), I have below proxy set with ~/.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
    
    0 讨论(0)
  • 2021-01-30 03:24

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

    0 讨论(0)
提交回复
热议问题