Ubuntu and Proxy
As always, use the below information with caution. Don't break any law/policy.
As a developer working within an enterprise, I would like to configure proxy setting for my Ubuntu VM, So that I can spend maximum time in developing software and not fight the MITM proxy setup
Set proxy variables for general work
If you're a superuser (root), then go ahead and create a new file with proxy settings as below. If not, add the below content to your .bashrc
$ cat /etc/profile.d/set-proxy.sh
export proxy=http://your.company.proxy:port
export no_proxy="localhost,127.0.0.1,yourcompany.domain.com"
export http_proxy=$proxy
export https_proxy=$proxy
export HTTP_PROXY=$proxy
export HTTPS_PROXY=$proxy
export NO_PROXY=$no_proxy
Set proxy for apt to work
To do the below, you have to be a superuser. Create a new file with the below content.
$ cat /etc/apt/apt.conf.d/95proxies
Acquire::http::proxy "http://your.company.proxy:port";
Acquire::http::Pipeline-Depth 0;
Acquire::http::No-Cache true;
Acquire::BrokenProxy true;
Bonus: CNTLM
Use cntlm to avoid writing your username and password everywhere. Some tools/libraries cannot work/do not work well with user/password based proxy URL's. Also, you'll have to use appropriate URL safe escape characters if you're password contains @, $, etc. (See this page from cyberciti.biz for more details) Once you have cntlm executable, you can start in foreground using the below command
$ cntlm -g -v -u userid@domain -I -r "User-Agent: curl/7.44.0" -l 3232 your.company.proxy:port
Once started, cntlm will ask for your password (if you haven't configured ini file). 3232 is the port on which cntlm will listen for http request. The above command also shows the possibility to set a pre-defined HTTP Header that will be sent to your company proxy. This is pretty useful, and dangerous when the MITM proxy might not allow certain applications to access the internet.