1

I'm running an app on Laravel Homestead. My OS is Windows 7. The hosts file:

192.168.10.10 myapp.dev

My PC uses the LAN Internet connection.

Now, I would like to be able to access myapp.dev on a mobile device.

I have tried this (1), as well as that (2). None of these worked for me. If I use the php artisan serve approach (link 1), my IPv4 gets rewritten to myapp.dev, and the site cannot be found.

How do I access my Homestead-based app on a phone?

lesssugar
  • 15,486
  • 18
  • 65
  • 115

1 Answers1

0

Homestead 5.x

As of Homestead 5.x, ngrok software is included in your homestead environment. You can use the share myapp.dev command to fire off ngrok to listen for myapp.dev. Please refer to the Laravel Homestead documentation (Sharing Your Environment)

Homestead versions without ngrok included

You can change your nginx configuration file to listen on all requests and use your local IP http://yourip:8000 instead of myapp.dev, but the easiest way to archive this is by creating a secure tunnel to your machine with software like ngrok.com

With your local domain myapp.dev you can basically run the following command after you served your webserver:

ngrok http 192.168.10.10:80 -host-header=myapp.dev

ngrok will generate a secure url which is available on your local network, but also publicly so you can share it with your friends/colleagues.

source

Craetive
  • 35
  • 6
  • 1
    And do I install and use ngrok on my Windows machine, or do I do this within the VM (when I'm ssh-ed to my environment with `vagrant ssh`)? – lesssugar Jun 21 '17 at 12:30
  • You can do both, but as of Homestead 5.x and up ngrok is included in your homestead environment. Please refer to the changes in my answer. – Craetive Jun 21 '17 at 12:59
  • That's a nice solution, but it is a bit flawed. E.g. if you use the `action()` helper to build URL-s, it will, of course, take you out of the ngrok.io domain (as it uses the `APP_URL` environment setting). This means you cannot move across the site freely. Overwriting the `APP_URL` after ngrok has started breaks the service. – lesssugar Jun 21 '17 at 15:44