简体   繁体   中英

Network configuration between nginx server (running on WSL) and Beeware app (Build and run from windows anaconda)

my web server is on wsl, and beeware is on anaconda (windows version not linux), how do I configure beeware app to communicate with wsl server. is there a feasible way? current I'm using ngrok host as a gateway. Is there any alternate way that doesn't require data packet to travel outside my system Is there any guide to develop a local system?

I'm going to attempt to answer this generically since I don't currently use Beeware/Anaconda. I tried skimming the Beeware docs, but too much of it (including the "publish", which might be a key element in the nginx integration) is "Coming soon".

Assuming there are no virtual machines or containers in the mix, Windows should detect ports on the WSL2 instance and map them correctly to localhost. For instance, if in WSL you python3 -m http.server 3000 , then you should be able to open that page in a Windows web browser at http://localhost:3000. So, by default, Anaconda on Windows should be able to access your web server in WSL through localhost. If this isn't happening:

  • First, make sure that nginx is listening on 0.0.0.0
  • Sometimes the Windows localhost auto-mapping seems to break. See this answer for some additional ideas. A quick-fix is often to just do a wsl --shutdown to reset the interfaces. A longer-term fix might be to disable Windows Fast Startup.

On the flip side, if there is any connection from nginx that needs to be made to Beeware/Anaconda, WSL2 does not map localhost back to the Windows host. You'll need to access it by the Windows host IP.

The easiest method is using mDNS, meaning from within WSL2 you can access the Windows host at the mDNS name " mycomputername .local", where mycomputername is the Windows "computer name".

See this answer for more details and alternatives if mDNS doesn't work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM