LoginSignup
0
0

More than 3 years have passed since last update.

Proxy環境下でWSL2を使うためのcltlm(ReverseProxy)

Posted at

状況

  • 会社でWSL2を使用したいけど、Proxyに阻まれてDockerやnpm等をインストールできない
  • NTLM認証のProxyを使用している(※最重要)
    • 下記のコマンドで、認証方法を指定すると通信できる
curl -U username:password --proxy-ntlm -x proxy.xxxx:8888 -L https://qiita.com

結論

  • ntlm認証に対応していないため、Wsl2から実行したapt-getコマンドなどが使用できなかった
  • そのため、Cntlm(ReverseProxy)をインストールし、そこを経由する image.png

設定方法

  • 1.Web上から、インストールファイルを取得
    • 同ページ上から遷移できるhttps://sourceforge.net/projects/cntlm/files/cntlm/cntlm%200.92.3/から、exeをDL
    • Verは一番新しい(といってもUpされたのは8年前だが)ファイルを取得した
  • 2.取得したファイルを実行し、インストール
    • 管理者権限が必要
  • 3.接続先のProxyを指定
    • デフォルトだと、C:\Program Files (x86)\Cntlmにインストールされた
    • cntlm.iniを以下のように修正
      • Username … Proxy認証する際に使用するユーザ
      • Domain … Proxyサーバのドメイン
      • Password … Proxy認証する際に使用するパスワード
      • Proxy … 1つ目は、Https通信用のポートを設定
      • Proxy … 2つ目は、Https通信用のポートを設定
  • 4. 動確(Cntlmが立ち上がっているか)
    • 以下のようにコマンドを実行し、HTTP Codeを確認
C:\Program Files (x86)\Cntlm>cntlm.exe -I -M https://qiita.com
Password:
Config profile  1/4... Auth not required (HTTP code: 400)
Config profile  2/4... Auth not required (HTTP code: 400)
Config profile  3/4... Auth not required (HTTP code: 400)
Config profile  4/4... Auth not required (HTTP code: 400)

Your proxy is open, you don't need another proxy.
  • 5. WSL2側のProxy設定
    • ~/.bashrcに、以下を追記
      • Ip指定でも構わない
      • WindowsとWSL2のIPが同じだった
HTTPS_PROXY=http://localhost:3128
HTTP_PROXY=http://localhost:3128
  • 6. 動確(WSL2)
    • Curlにオプションを指定せず、該当の処理が完了すれば設定完了 curl https://qiita.com
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0