Xian55 / WowClassicGrindBot

Highly configurable and responsive World of Warcraft Classic pixel Grind Bot - No DLL injection or memory tampering, just screen capture and input simulation.
161 stars 117 forks source link

Modification in launchsettings.json to connect to Blazor Server from a Windows Virtual Machine using Ubuntu #564

Closed Cybereu closed 6 months ago

Cybereu commented 6 months ago

I would like to share a solution I found to connect to a Blazor Server hosted on a Windows virtual machine using Ubuntu network bridged. I encountered an issue with the default configuration in the launchsettings.json file, where the application URL was set to "http://localhost:5000/".

When attempting to connect to the Blazor Server from a Windows virtual machine using Ubuntu, the default URL "http://localhost:5000/" was not working.

I modified the launchsettings.json file to reflect the following change:

"applicationUrl": "http://localhost:5000" --> "applicationUrl": "http://0.0.0.0:5000"

I don´t know if it is a specifig problem with my setup but Blazor Server could be accessed from outside the virtual machine. Changing from "localhost" to "0.0.0.0" allows the application to listen on all available network interfaces in the virtual machine.

Security Note: It's important to mention that this solution comes with some security risks. Modifying the launchsettings.json to listen on all interfaces may expose the application to potential security threats.

Xian55 commented 6 months ago

Hello here,

I'm glad you managed to find out how to solve the issue on your own.

What you said about changing the "applicationUrl" hold true as well, including the potential security risk. By recommendation during the app is in development stage, it is considered a good practice to use 127.0.0.1/localhost.

Once the application is ready for external testing or production it is more advised to prefer 0.0.0.0/* to let external devices gain access to the site - depending on the planned availability of course. As you pointed out using all wildcard can lead to security risk without proper configuration on the host machine.

On the other hand just alone editing the launchsettings.json would not be sufficient to completely solve the problem what you encountered, as launchsettings.json is primarily used while developing the app in IDE such as Visual Studio or Visual Studio Code, etc...

There are other ways to start the application. Such as using the command line

dotnet run --urls=http://localhost:5000

Nonetheless, you correctly pointed out a possible issue, if you intend to host any application in an environment where you expect to external devices gain access to your site/app. Then you have to make the previously mentioned changes.

Not so long ago, i got a private message about, an issue of unable to access the PathingAPI rest endpoints. The use case was that the individual wanted to host the app in a VPS(Virtual Private Server) in a cloud. He was facing the same issue what you described, and come to the same conclusion to solve the issue.

In my humble opinion, this kind of issue is out of scope of the project. All the tools are available to make your changes to suit your needs.

Thank your for your time, and have a nice day, Gooday