Allow outside & other devices (phones, tablets,...) to access your local server using ngrok


  • administrators
    | 52456 points

    Laragon 1.0.7 includes ngrok, an excellent tool to expose your local server behind a NAT or firewall to the internet.
    This tutorial helps you to allow connections from outside to your [project.dev]

    1. Make sure of our services is running (Start All), press Ctrl + Alt + T to open Terminal
     Ctrl + Alt + T
    
    1. Run ngrok by typing: ngrok http project.dev:80
     ngrok http project.dev:80 
    
    1. Ngrok will start and show status screen, note for a domain which looks like this: xxxxxxxx.ngrok.io (in that case: 3e66ccf0.ngrok.io)
    Forwarding                    http://3e66ccf0.ngrok.io -> project.dev:80  
    
    1. Open http-vhosts.conf (Menu > Apache > http-vhosts.conf), and add the domain to ServerAlias of project.dev Virtualhost entry:
    <VirtualHost *:80> #laragon magic!
        DocumentRoot "d:/laragon107.2/www/project/"
        ServerName project.dev
        ServerAlias *.project.dev, 3e66ccf0.ngrok.io
    </VirtualHost>
    
    1. Reload Apache (Menu > Apache > Reload). That's all.
      DONE! You and your customers now can access your project.dev from anywhere using this url:
      http://3e66ccf0.ngrok.io

    Note: The url will be changed each time you run ngrok.


    Some pics:

    1. Run ngrok:
      0_1459146452904_ngrok-run.png

    2. Add ngrok.io url to ServerAlias:
      0_1459146550132_ngrok-serveralias.png

    3. Reload Apache (You also can click Reload button in Laragon Interface):
      0_1459146597638_reload-menu.png


  • | 59 points

    This is even faster:
    ngrok http -host-header=myapp.dev 80

    Just write this and it works.


  • administrators
    | 52456 points

    @crissi : There are cases it doesn't work.
    For example, if you have a Wordpress project: ** wp.dev**
    When browsing http://xxxx.ngrok.io, the browser will redirect to http://wp.dev


  • | 67 points

    there is a simplest way

    • run the PHP server from the prefernces,
      the project will work on port 8000, so if you have a website called project.dev it will work the same way but on localhost:8000
    • then run ngork by typing:
      ngrok http localhost:8000

Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.