I wanted to tidy away a server and mover to using docker containers under WSL. That's a story for another day.
There is a lot written on this and the [[https://github.com/microsoft/WSL/issues/10494][problems associated with it].
What to do.
There are scripts that never quite worked for me.
One of the problems is that WSL2 gets a new IP address with each reboot. Arrgh!.
My simple solution was to proxy traffic that comes to the target port to the localhost (and thence automagically to WSL2), like this.
powershell in Administration mode I did this proxy:
netsh interface portproxy add v4tov4 listenport=9443 listenaddress=0.0.0.0 connectport=9443 connectaddress=127.0.0.1
Great. On my machine running WSL (example.com), I can now access the server as https://example.com:9443.
All I need to do is to expose that port now, so that systems on local LAN can get through Windows Firewall. Back in
powershell I run
wf and set a rule to allow access to port 9443 on this machine (example.com).
Yay! It all works.