I'm in an environment that uses complex proxy settings and uses .pac file to describe/resolve them. I want to setup some VM's and docker containers on this environment mainly based on ubuntu. The typical "system --> preferences --> network proxy --> apply system wide" answer doesn't help a lot because I don't have access to the UI. Ideally a solution would apply really system-wide i.e. work with curl
, wget
, apt-get
, pip
and maven
. Is there such solution?
The PAC file essentially consists of a JavaScript function. The return statement (one or more) of the function returns the proxy server address and port, for example: Just look at your PAC file by entering its address in a browser. With this information you can create an APT configuration file:
I do not know if APT is able to use a PAC file directly but you can (with quite a bit of work/understanding) extract the relevant proxy information from the PAC file itself and use this information to configure APT to use a HTTP proxy. The PAC file essentially consists of a JavaScript function.
The PAC file essentially consists of a JavaScript function. The return statement (one or more) of the function returns the proxy server address and port, for example: return "PROXY proxy.some.site:8080; DIRECT"; Just look at your PAC file by entering its address in a browser.
A PAC file needs to be interpreted with javascript. The majority (if not all) programs that make use of the http_proxy environment variable will not be able to interpret this file in order to make user of it.
From command line there is no option for setting "system wide" proxy, you must set variables in several files depeding on application user.
Almost all command line applications
Edit /etc/environment
http_proxy=http://user:password@proxy:port/
https_proxy=http://user:password@proxy:port/
ftp_proxy=http://user:password@proxy:port/
no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
HTTP_PROXY=http://user:password@proxy:port/
HTTPS_PROXY=http://user:password@proxy:port/
FTP_PROXY=http://user:password@proxy:port/
NO_PROXY="localhost,127.0.0.1,localaddress,.localdomain.com"
WGET
Edit /etc/wgetrc
http_proxy=http://user:password@proxy:port/
https_proxy=http://user:password@proxy:port/
ftp_proxy=http://user:password@proxy:port/
APT
Edit or create /etc/apt/apt.conf.d/95proxy
Acquire::http::proxy "http://user:password@proxy:port/";
Acquire::ftp::proxy "ftp://user:password@proxy:port/";
Acquire::https::proxy "https://user:password@proxy:port/";
CURL
Edit or create in your home ~/.curl.rc
proxy = user:password@proxy:port
PIP
I didn't find a complete solution for PIP, so I'd rather recommend to use pip with command variable --proxy
pip --proxy <proxy> install <module>
MAVEN
I've never used maven although I've found this
Hopes it helps you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With