Vagrant port forwarding 80 to 8000 with Laravel Homestead

前端 未结 3 1119
我寻月下人不归
我寻月下人不归 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:41

    You should continue to use ports above 1024 since they are non-privileged ports, BUT if you do want you can run as port 80 on the Homestead VM, as long as you don't have anything holding on to that port on the host machine. Just tried it and it worked, with a few gotchas. First, you change that line in the .rb file from:

    config.vm.network "forwarded_port", guest: 80, host: 8000

    to

    config.vm.network "forwarded_port", guest: 80, host: 80

    When you fire your VM up after saving you will get a warning from vagrant:

    ==> default: You are trying to forward to privileged ports (ports <= 1024). Most

    ==> default: operating systems restrict this to only privileged process (typically

    ==> default: processes running as an administrative user). This is a warning in case

    ==> default: the port forwarding doesn't work. If any problems occur, please try a

    ==> default: port higher than 1024.

    ==> default: Forwarding ports...

    default: 80 => 80 (adapter 1)
    

    But it worked for me. Now, to actually get to the VM I had to use it's private IP instead of the localhost name:

    http://192.168.10.10/
    

    But sure enough my site was there and everything was working. If you decide to keep it that was you can add that IP address to your hosts file to give it a nice short name.

    Hope this helps.

提交回复
热议问题