V
V
Viktor2015-02-08 01:23:57
linux
Viktor, 2015-02-08 01:23:57

Virtualbox port forwarding - windows 8 and ubuntu 14.04, how to open local sites from virtual box?

Installed Ubuntu with LEMP in virtual box.
I set up SSH and SFTP access to the guest from under the host (based on this manual). Through port forwarding - 2222 to 22. Everything works.
I thought I could just as easily forward all my local sites from the virtual machine to the host system. In virtualbox, in the settings of the virtual machine, I prescribe: I go to 127.0.0.1:8080
abc8e72642d243f9a9d2ab7097e408b3.png
in the host system browser - everything is according to plan, the Ngnix server stub is shown. The most interesting. I'm trying to go to my example.com site deployed in the virtual machine from under the host: example.com:8080 - and the site does not load. Although everything is displayed in the virtual machine in the browser (of course, after adding the entry 127.0.0.1 example.com to /etc/hosts
.
I tried adding the appropriate entry to the hosts file of the host system (windows 8 in my case) - and nothing, the site is not shown.
So what am I doing wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor, 2015-02-08
@victafonenko

Solved the problem completely. Below is the manual.
To make everything work, (SSH access, + access to local virtual machine sites):
1) Create a virtual machine. To taste, we set up a web server, with the site example.com installed on the localhost, for example. / We also set the OpenSSH server:
2) Turn off the virtual machine, go to Machine - Configure - Network - Adapter 1 (select the type of NAT connection) - Port Forwarding . There we set the following settings:
Where Rule 1 will allow you to connect via SSH / SFTP to the virtual machine from under the host system on port 2222 . Rule 2 forwards all connections on port 80(http) host system to the virtual machine on port 80 .
With these settings, SSH will already work, but the local sites of the virtual machine web server will not be shown on the host system yet.
3) Next, in the same window, Network settings of the virtual machine, connect the second network adapter ( Adapter 2 ) with the internal network:
Save everything, start the virtual machine.
4) Next, edit the hosts file of the host system. On Windows, this is usually Windows\System32\drivers\etc\hosts . We add an entry like 127.0.0.1 example.com there (this means that when we go to example.com, we should be redirected to localhost) That
's it. at example.comin the browser of the host system, our local website should open on the web server of the virtual machine.
If there is a linux-desktop virtual machine, and we want our local site example.com to open in the browser there, then we add a similar entry 127.0.0.1 example.com to the hosts file of the virtual machine at /etc/hosts
Links for thought leonid.shevtsov. me/ru/installing-ubuntu-linux-on-v... and leonid.shevtsov.me/ru/virtuabox-ubuntu-configurati...

N
Nazar Mokrinsky, 2015-02-08
@nazarpc

Compare the default config with yours, show the ifconfig output from the virtual machine, and the config of the site itself would not hurt either.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question