1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

WSL2にcode-serverをインストールして外部アクセス可能にする

Last updated at Posted at 2021-02-10

code serverのインストール

curl -fsSL https://code-server.dev/install.sh | sh

WSL2でcode serverの起動

passwordは任意のものを入れておく

PASSWORD=password code-server --bind-addr=0.0.0.0:8080 --auth=password --allow-http

windows側のポートフォワードの設定

netshを使ってポートフォワードする

ポートフォワードするにはまずWLS2のIPアドレスを知る必要がある。
これは再起動するたびに可変なので注意

wls2側で実行

hostname -I

IPアドレスが確認できたので、上記IPアドレスを使ってポートフォワードの設定を行う。
管理者権限でのpowershellにて実行

netsh.exe interface portproxy add v4tov4 listenport=8080 connectaddress={WLS2 IP}

設定できたかの確認は以下

netsh interface portproxy show v4tov4

8080ポートの解放

Windows PowerShellにて実行

New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' -Direction Inbound -LocalPort 8080 -Action Allow -Protocol TCP
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?