Answer the question
In order to leave comments, you need to log in
Is it possible to open in the browser a site that has been launched on a virtual machine?
There is Debian 10 on a virtual machine in qemu kvm, I put php, laravel, nginx there. Created a project in laravel. Ran it at 127.0.0.1:8000. Everything works fine, but how can I make the project that I launched in the virtual machine be displayed in the browser on the host OS.
Help me please. I will be very grateful.
Answer the question
In order to leave comments, you need to log in
Good time.
Since your question is highlighted on FL Habr, in order not to lose one answer there, I will comment here.
The virtual machine allows you to deploy a guest OS inside the host machine. The guest OS is an "isolated" installation of sorts, so anything that relates to setting up a regular server's networking refers to setting up a guest OS's networking. You have created a local network inside the KVM virtualization host, so the usual means like ping and ifconfig can get the addresses of the machines. Next, we make the necessary settings in the configs so that nginx is available from the virtualization host, example curl http://192.168.0.2:80/index.html.
Further options are possible - port forwarding using the IP firewall of the host OS or raising the nginx proxy.
firstly, in this case it should be launched not on 127.0.0.1, but, for example, on 0.0.0.0.
secondly, the network adapter of the virtual machine must be configured for the host system as a network bridge"
You need to configure port forwarding from the host to the guest and connect accordingly.
well, for example something like this:
/usr/bin/qemu-system-x86_64 \
....
-net user,hostfwd=tcp::8000-:8000 \
-net nic
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question