Recently I came accross the issue of wanting to install apt packages in WSL behind a corporate proxy. Plus I wanted to update my yarn package by using “curl -o- -L https://yarnpkg.com/install.sh | bash” which also needs to go through the proxy.

The solution is the same as if we want to set the proxy in a standard Ubuntu. So simply create a proxy.conf inside the apt config folder as follows.

vi /etc/apt/apt.conf.d/proxy.conf
# add the following line (press i to insert and escape followed by :x to save)
Acquire::http::Proxy "http://username:password@myproxy:myproxyport";

Aditionally we need to set the proxy for curl. For that we create or modify an user specific ~/.curlrc file in our homefolder.

cd ~/
vi .curlrc
# insert the following line
proxy = <proxy_host>:<proxy_port>

Thats it. You are now using apt and curl through your corporate proxy.


2 Comments

Eric · 29. September 2020 at 21:40

dumb question but in the proxy for curl do we need to include the brackets?

    Michael · 30. September 2020 at 6:48

    No you simply put it in the host and port, like this:

    proxy=myproxy:8080

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: