F
F
fdkur342020-02-11 01:10:24
Nginx
fdkur34, 2020-02-11 01:10:24

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

3 answer(s)
D
Dmitry Luponos, 2020-02-25
@fdkur34

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.

V
vreitech, 2020-02-11
@fzfx

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"

S
Sergey c0re, 2020-02-11
@erge

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

on the host connect to 127.0.0.1:8000

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question