9

as I know, Linux is case-sensitive. and I usually export the http proxy like the below:

export http_proxy= proxy:port export https_proxy= proxy:port

so I think that if I wrote like the below, it would work.

export HTTP_PROXY= proxy:port export HTTPS_PROXY= proxy:port

but, it also works, and I want to know the reason, and why this works.

and I find a description at here: http://curl.haxx.se/docs/manpage.html

The environment variables can be specified in lower case or upper case. The lower case version has precedence. http_proxy is an exception as it is only available in lower case.

does this convention can applied everywhere?

ref:

  1. http://pubs.opengroup.org/onlinepubs/7908799/xbd/envvar.html
  2. http://www.ee.surrey.ac.uk/Teaching/Unix/unix8.html
  3. http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_02.html
  4. http://sc.tamu.edu/help/general/unix/vars.html
1

2 Answers 2

3

actually I can not get the exact answer.
but after I investigation, I think the only reason is that,
all the applications which need internet connection that will try to find the both
1. https_proxy
2. HTTPS_PROXY.
if one of them beed set up, it will use that to connect the internet.

1

In general, environment variables are written in uppercase. http_proxy is exception sometimes. For instance, variable HTTP_PROXY can be controlled by attackers in CGI environments, as in golang/go#16405:

  • The CGI spec defines that incoming request header "Foo: Bar" maps to environment variable HTTP_FOO == "Bar". (see RFC 3875 4.1.18)

  • The HTTP_PROXY environment variable is conventionally used to configure the HTTP proxy for HTTP clients (and is respected by default for Go's net/http.Client and Transport)

So it really depends on a program (of course they may uses proxy settings in rc or config file):

  • curl uses http_proxy, HTTPS_PROXY, NO_PROXY (reference)
  • wget uses http_proxy, https_proxy, no_proxy (reference)

You may set up environment variable in both cases to be sure, for example:

export http_proxy=http://proxy.my.com:8080
export https_proxy=http://proxy.my.com:8080
export no_proxy=.host1,.my.com,.local
# reuse values for another case
export HTTP_PROXY=${http_proxy}
export HTTPS_PROXY=${https_proxy}
export NO_PROXY=${no_proxy}

There is a similar topic https://unix.stackexchange.com/questions/212894/whats-the-right-format-for-the-http-proxy-environment-variable-caps-or-no-ca

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .