2

I have multiple sites in laravel homestead. Now, I want to access a spezific site via the ip in my local network. But I get allways the site I dont want...

homestead.yaml

sites:
- map: mdb.local
  to: /home/vagrant/code/mdb/public
  type: "apache"

- map: zz.tested
  to: /home/vagrant/code/abc/public
  type: "apache"

- map: 192.168.10.10
  to: /home/vagrant/code/mdb/public

And my hosts

192.168.10.10 mdb.local
192.168.10.10 zz.tested

I can access both on my computer with the domain, however I allways get abc over the ip in the local network. What do I have to change to get mdb on mobile and abc is accessable only on my computer?

I've read this StackOverflow Question but - you can see my implementation of this solution - it doesn't help to solve this problem.

Patrick Schocke
  • 1,493
  • 2
  • 13
  • 25

2 Answers2

3

Apache always takes the first site alphabetically and returns that as the default host. What you can do is to make a host called 000default or similar, which will then be returned when there's no hostname.

Simon Fredsted
  • 964
  • 2
  • 14
  • 26
1

You can accomplish this by configuring the second app/site to run on port 81 rather than port 80, and then setting up a port forward to send 8001 or 8100 to 81.

sites:
- map: mdb.local
  to: /home/vagrant/code/mdb/public
  type: "apache"
  port: 81

- map: zz.tested
  to: /home/vagrant/code/abc/public
  type: "apache"

ports:
  - send: 8100
    to: 81

With this, you should be able to access your mdb application via the correct port. From inside Homestead, that would be 81. From outside, that would be 8100. The port is needed regardless of whether you are using the host machine's IP address (e.g. http://192.168.1.5:8100) or a hosts entry (e.g. http://mdb.local:8100).

Trip
  • 2,018
  • 15
  • 27
  • You can use any unused ports. It doesn't have to be 81, 8001, and/or 8100. – Trip Dec 11 '18 at 04:17
  • The one caveat: From the host machine, you would obviously need to access the `mdb.local` application on port 81 instead of the normal default of 80. – Trip Dec 13 '18 at 03:08