Windows Subsystem for Linux (WSL) behind Proxy

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.

1
vi /etc/apt/apt.conf.d/proxy.conf
1
2
# 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.

1
vi ~/.curlrc
1
2
3
4
# insert the following line
proxy = <proxy_host>:<proxy_port>;
# for example
# proxy = my-proxy:8080

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