Задать вопрос
@misterobot404

Как получить доступ к сайту из общественной сети?

Здравствуйте. Не получается наладить доступ к сайту в homestead из общественной сети. До этого полный доступ был через nat: роутер->хостовая машина->vagrantbox сайт открывался по ip роутера без проблем, но сегодня нужно было получить доступ к сайту outside, и он ,конечно же, не открылся. Видимо доступ имеется только через внутреннюю сеть. После этого для vagrantbox создал мост, теперь подключение роутер->vagrantbox, та же самая история.

Vagrantfile:
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.network "public_network"

Homestead.yaml:
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Source
to: /home/vagrant/code
sites:
- map: clever-2019-dynamic-map.app
to: /home/vagrant/code/clever-2019-dynamic-map/public
databases:
- homestead

vagrant up:
$ vagrant reload
==> homestead-7: Attempting graceful shutdown of VM...
==> homestead-7: Checking if box 'laravel/homestead' version '7.2.1' is up to date...
==> homestead-7: Clearing any previously set forwarded ports...
==> homestead-7: Clearing any previously set network interfaces...
==> homestead-7: Preparing network interfaces based on configuration...
homestead-7: Adapter 1: nat
homestead-7: Adapter 2: bridged
homestead-7: Adapter 3: hostonly
==> homestead-7: Forwarding ports...
homestead-7: 80 (guest) => 8000 (host) (adapter 1)
homestead-7: 443 (guest) => 44300 (host) (adapter 1)
homestead-7: 3306 (guest) => 33060 (host) (adapter 1)
homestead-7: 4040 (guest) => 4040 (host) (adapter 1)
homestead-7: 5432 (guest) => 54320 (host) (adapter 1)
homestead-7: 8025 (guest) => 8025 (host) (adapter 1)
homestead-7: 9600 (guest) => 9600 (host) (adapter 1)
homestead-7: 27017 (guest) => 27017 (host) (adapter 1)
homestead-7: 22 (guest) => 2222 (host) (adapter 1)
==> homestead-7: Running 'pre-boot' VM customizations...
==> homestead-7: Booting VM...
==> homestead-7: Waiting for machine to boot. This may take a few minutes...
homestead-7: SSH address: 127.0.0.1:2222
homestead-7: SSH username: vagrant
homestead-7: SSH auth method: private key
==> homestead-7: Machine booted and ready!
==> homestead-7: Checking for guest additions in VM...
==> homestead-7: Setting hostname...
==> homestead-7: Configuring and enabling network interfaces...
==> homestead-7: Mounting shared folders...
homestead-7: /vagrant => C:/Users/misterobot/Homestead
homestead-7: /home/vagrant/code => C:/Users/misterobot/Source
==> homestead-7: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> homestead-7: flag to force provisioning. Provisioners marked to run always will still run.
  • Вопрос задан
  • 104 просмотра
Подписаться 1 Простой Комментировать
Решения вопроса 1
@misterobot404 Автор вопроса
Проблему решил, причина была в том, что vagrant пробрасывал порты во внутренюю сеть, но из за того что по внешнему адресу сайт был доступен из внутренней сети не обратил на это внимание. Изменить это можно так:

You can easily access your Vagrant from any machine on your network, by simply ensuring that the port forwarding rules aren't bound to your localhost (127.0.0.1).

If you're using VirtualBox as your provider, you can change this on the fly, so you can have it be private by default (which is of course more secure), and then you can go change it in VirtualBox while your VM is running to expose the port to other machines on your network (and possibly the internet, so be careful!)

To expose the port:
Start Virtual Box
Select your VM in the left hand side bar
Click Settings | Network | Advanced | Port Forwarding
Find the port you want to expose in the port list
Set it's Host IP to an empty string, and click OK.
The port is now available to other machines on your network, and possibly the internet, so don't do this unless you're positive you're ok with opening up the port!

Of course to revert it, just do the same process and set the Host IP to 127.0.0.1 again.
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы