Vagrant port forwarding 80 to 8000 with Laravel Homestead

前端 未结 3 1087
我寻月下人不归
我寻月下人不归 2021-01-07 00:25

My Problem:

I can only access my sites through port 8000, but not 80, which makes me think it is not redirecting 80 to 8000 as it says it should be.

3条回答
  •  孤城傲影
    2021-01-07 00:44

    I'm not sure what the confusion is - this is the way it's supposed to work.

    The web server on the VM listens on port 80. Vagrant/VirtualBox forwards that port from 80 (on the VM) to 8000 (on localhost) so that you can access the site at http://localhost:8000.

    Port 80 on the VM's domain name is not going to be available - that domain name probably resolves to localhost.

    Try the following: dig local.kujif.com (or nslookup or even ping - I don't know what tools are available on Windows) to find out what IP address that name is resolving to. You will probably find that it's 127.0.0.1 (localhost).

    You could try using the IP address set in the homestead file instead: http://192.168.10.10/ - this might work, but it will depend on how networking is configured in the VM.

    Ideally, you need to set networking to "bridged" in the VM - this will make the VM look (to your network) like any other device on the network. Other networking options in the VM (sorry, I'm not familiar with the options in VirtualBox) will set the VM up with its own network that is not accessible outside the VM - this is why port forwarding is used to expose network services on the VM.

提交回复
热议问题