Windows10でWSL(Windows Subsystem for Linux)のプロキシ設定をしたぜ

apt-getしようとしたらconnection refuseした。

> chino@kafu:~$ sudo apt update
> [sudo] password for chino:
> Err:1 http://archive.ubuntu.com/ubuntu bionic InRelease
> Could not connect to archive.ubuntu.com:80 (2001:67c:1560:8001::11). - connect (111: Connection refused)

 

1. windows環境変数の編集で
HTTP_PROXY : <proxyのIPアドレス/URL>:<port番号>
HTTPS_PROXY : <proxyのIPアドレス/URL>:<port番号>
を追加

 

2. WSL(Windows Subsystem for Linux)のUbuntu
$ export http_proxy="<proxyのIPアドレス/URL>:<port番号>"
$ export https_proxy="<proxyのIPアドレス/URL>:<port番号>"


3. /etc/apt/apt.confを新規作成
$ sudo vi /etc/apt/apt.conf
> Acquire::ftp::proxy "<proxyのIPアドレス/URL>:<port番号>";
> Acquire::http::proxy "<proxyのIPアドレス/URL>:<port番号>";
> Acquire::https::proxy "<proxyのIPアドレス/URL>:<port番号>";

 

3番で、;(セミコロン)を忘れると
> chino@kafu:~$ sudo apt update
> E: Syntax error /etc/apt/apt.conf:4: Extra junk at end of file

 

1と2だけやって、3の/etc/apt/apt.confの作成をせずに、
3なくてもいけるだろうとapt updateしたところ、connection refuseした。
プロキシ要因か確かめるために、プロキシを指定して、curlを打ったら通った。
> chino@kafu:~$ curl -x <proxyのIPアドレス/URL>:<port番号> -L http://www.tomorinao.space/
> <html>
> <title>Hello, tomorinao</title>
> <body>

 

 

 

--- 参考 ---
1. http://d.hatena.ne.jp/mrgoofy33/20100726/1280154695
2. http://namihira.hatenablog.com/entry/2013/12/29/170839
3. http://demura.net/lecture/15309.html
4. http://blog.syo-ko.com/?eid=2441
5. https://qiita.com/mino_s2000/items/7624b507ac885e17d36c
6. https://nagayasu-shinya.com/wsl-proxy-setting/