Using Environment Variables to Set a Proxy

Proxy environment variable values apply to all URIs of that protocol. At runtime, values of http_proxy environment variables override values set with the --proxy option of the pkg set-publisher command. See the ENVIRONMENT section of the curl(1) man page for additional information about proxy environment variables and the list of accepted environment variable names.

In the following example, the value of proxyURI is the following:

[http://|https://](host-name|ipv4_address|[ipv6_address])[:port]
  • The scheme can be http:// or https://. If the scheme is not specified, http:// is assumed.

  • The proxy must contain the host name or dotted numerical IP address.

    A numerical IPv6 address must be written within brackets: [].

  • To specify the port number, append :port to the end of the host name. If not specified, the default port is 1080.

If you set http_proxy environment variables in an image that has non-global zones, then in the global zone, set the proxy properties in the svc:/application/pkg/system-repository SMF service to these same values and refresh the service.

If you change the value of an http_proxy environment variable, be sure to update the system-repository service properties and refresh the service.

$ svccfg -s system-repository:default setprop config/http_proxy = proxyURI
$ svccfg -s system-repository:default listprop config/*proxy
config/https_proxy astring
config/http_proxy  astring     proxyURI
$ svcprop system-repository:default | grep proxy
config/https_proxy astring ""
config/http_proxy astring ""
$ svcadm refresh system-repository:default
$ svcprop system-repository:default | grep proxy
config/https_proxy astring ""
config/http_proxy astring proxyURI

The pkg publisher command does not show proxies that were set by setting environment variables or SMF service properties.