This article will discuss the settings for working correctly in WSL from under the proxy for:


  • apt-get
  • curl
  • wget
  • git
  • npm

Apt-get


Note: hereinafter, the following proxy data is used:


  • host: CDMY0CDMY
  • port: CDMY1CDMY
  • login: CDMY2CDMY
  • password: CDMY3CDMY

For CDMY4CDMY to work correctly, add the line CDMY5CDMY to the CDMY6CDMY file
To do this, you can run the command


sudo cat <<EOF >>/etc/apt/apt.conf.d/proxy.conf Acquire::http::Proxy "http://user@example.com:somePassword@proxy.example.com:7777"; EOF 

Check the correctness of the settings:


cat/etc/apt/apt.conf.d/proxy.conf 

The result should contain:


Acquire::http::Proxy "http://user@example.com:somePassword@proxy.example.com:7777"; 

Then you need to exit WSL and, after re-logging in, check that it works correctly, for example, by doing:


sudo apt-get update -y 

Curl


If the login and/or password does not contain CDMY7CDMY, then you can limit yourself to adding the environment variable CDMY8CDMY with the value CDMY9CDMY.


If the proxy does not require authorization, then CDMY10CDMY.


You can do this with the command:


cat <<EOF >> ~/.profile export http_proxy=http://user:somePassword@proxy.example.com:7777 EOF 

In order not to restart WSL, you can run the command:


source ~/.profile 

But in our case we’ll have to create a CDMY11CDMY file with the following contents:


proxy-user=user@example.com:somePassword proxy=http://proxy.example.com:7777 

You can do this by running the command:


cat <<EOF >> ~/.curlrc proxy-user=user@example.com:somePassword proxy=http://proxy.example.com:7777 EOF 

Wget


If the login and/or password does not contain CDMY12CDMY or the proxy does not require authorization, then you can use the appropriate steps for CDMY13CDMY if they have not been done before.
In our case, create the CDMY14CDMY file with the following contents:


proxy-user=user@example.com proxy-password=somePassword http_proxy=http://proxy.example.com:7777 use_proxy=on 

You can do this with the command:


cat <<EOF >> ~/.wgetrc proxy-user=user@example.com proxy-password=somePassword http_proxy=http://proxy.example.com:7777 use_proxy=on EOF 

A few more commands remain for CDMY15CDMY and CDMY16CDMY.


Git


git config --global http.proxy "http://user@example.com:somePasswrod@proxy.example.com:7777" 

Npma


npm set proxy http://user@example.com:somePassword@proxy.example.com:7777/npm set https-proxy http://user@example.com:somePassword@proxy.example.com:7777/ 

UPD 1: typos and inaccuracies in the comments DaemonGloom and achekalin .

.

Source