Access server in WSL through Windows network
Open a hotspot in Windows
Add a proxy in Windows to access WSL deployed apps through Windows localhost
In powershell execute the following command:
netsh interface portproxy add v4tov4 listenport=4000 listenaddress=0.0.0.0 connectport=8080 connectaddress=192.168.1.4
- listenport: the port external devices will connect to
- connectport: the port where our application server is configured to listen inside WSL
- connectaddress: IP address given to WSL. To get this IP address get
inet
ofeht0
throughifconfig
Open port (listenport) in Windows firewall
Get the access url to use in devices connected to Windows hotspot ipconfig and get ip address. Example:
http://192.168.137.1:4000/test