Coder Social home page Coder Social logo

laravel-ngrok's Introduction

Total Downloads Latest Stable Version License

Share Laravel application with ngrok

This package allows you to share your Laravel application with ngrok.

Requirements

  • Ngrok >= 2.2.8 (If you are using Laravel Homestead this should be already installed)

Version Compatibility

Laravel Laravel Ngrok
5.8.x 1.x
6.x 1.x
7.x 1.x
8.x 2.x
9.x 2.x
10.x 3.x
11.x 3.x

Installation

You can install the package via composer:

composer require --dev jn-jairo/laravel-ngrok

The NgrokServiceProvider will be automatically registered for you.

Usage

Just call the artisan command to start the ngrok.

php artisan ngrok

The parameters for ngrok will be extracted from your application.

Advanced usage

php artisan ngrok [options] [--] [<host-header>]
Argument Description
host-header Host header to identify the app (Example: myapp.test)
Option Description
-H, --host[=HOST] Host to tunnel the requests (default: localhost)
-P, --port[=PORT] Port to tunnel the requests (default: 80)
-E, --extra[=EXTRA] Extra arguments to ngrok command (multiple values allowed)

Examples

# If you have multiples apps (myapp.test, my-other-app.test, ...)
# set it in the app.url configuration
# or pass it in the host-header argument

php artisan ngrok myapp.test

# If you use a different port, set it in the app.url configuration
# or pass it in the --port option

php artisan ngrok --port=8000 myapp.test

# If you use docker and have containers like (nginx, php, workspace)
# and wanna run the command inside the workspace container
# pass the name of the container the requests will tunnel through

php artisan ngrok --host=nginx example.com

# If you wanna pass other arguments directly to ngrok
# use the --extra or -E option

php artisan ngrok --extra='--region=eu' -E'--config=ngrok.yml'

License

The MIT License (MIT). Please see License File for more information.

laravel-ngrok's People

Contributors

jn-jairo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

laravel-ngrok's Issues

PHP Version v8.0.8 Not Compatible For Laravel Framework Version v8.40

  • Version: 2.0.0
  • PHP Version: 8.0.8
  • Laravel Framework Version: 8.40

Describe the bug
Having an issue with the PHP version not being supported states it only supports version ^7.3 the latest suggested version for Laravel 8.40 is 8.0.8. Can't use this plugin unless this issue is fixed.

To Reproduce
Steps to reproduce the behavior:

  1. Install fresh laravel version.
  2. install sail to get docker setup.
  3. attempt to install plugin with "sail composer require --dev jn-jairo/laravel-ngrok"
  4. See error in console about PHP version.

Expected behavior
Would expect it to work the newer versions of PHP.

Laravel 9 using Homestead getting redirect not working

Is there something more I need to do than the basic instructions? I'm running several sites locally using Homestead and Nginx.
I've tried the commands:

vagrant@homestead:~/sites/biospexDev$ art ngrok --host=nginx dev.biospex.test
-----------------
|     NGROK     |
-----------------

Host header: dev.biospex.test
Host: nginx
Port: 80

Web Interface: http://192.168.10.10:4040

Forwarding: https://efcb-69-246-163-107.ngrok.io -> http://nginx:80
Forwarding: http://efcb-69-246-163-107.ngrok.io -> http://nginx:80

Resulting in

Failed to complete tunnel connection

The connection to http://efcb-69-246-163-107.ngrok.io/ was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address [nginx:80](http://nginx/).

Make sure that a web service is running on [nginx:80](http://nginx/) and that it is a valid address.

The error encountered was: dial tcp: lookup nginx on 127.0.0.53:53: server misbehaving

And

vagrant@homestead:~/sites/biospexDev$ art ngrok --host=dev.biospex.test
-----------------
|     NGROK     |
-----------------

Host header: dev.biospex.test
Host: dev.biospex.test
Port: 80

Web Interface: http://192.168.10.10:4040

Forwarding: https://0a62-69-246-163-107.ngrok.io -> http://dev.biospex.test:80
Forwarding: http://0a62-69-246-163-107.ngrok.io -> http://dev.biospex.test:80

Results in "The page isn’t redirecting properly"

In my Nginx site configs, I do redirect http to https. Could that be causing the issue? The redirects work normally when accessing from a browser on my computer.

Appreciate any feedback.

Laravel 10 support?

I tried to use it with Larvel 10 but encountered this: jn-jairo/laravel-ngrok v2.0.0 requires php ^7.3 -> your php version (8.1.16) does not satisfy that requirement.

May I know when the new version with Laravel 10 support is released?

Thanks!

Can not start ngrok, ngrok not found

  • Version: #.#.#
  • PHP Version: 8.1
  • Laravel Framework Version: 9.0
  • Ngrok Version: 3.0.5

Describe the bug
When running php artisan ngrok, the next is returned :


| NGROK |

Host header: 0ea7-2a02-a45c-6ca4-1-64c3-aa90-f163-e561.eu.ngrok.io
Host: localhost
Port: 80

sh: line 0: exec: ngrok: not found

To Reproduce
Steps to reproduce the behavior:

  1. Install ngrok ( macos ) save on Desktop
  2. Make an alias : alias ngrok="~/Desktop/ngrok"
  3. Go to your application root ( valet, ~/Sites/MyApp )
  4. Run php artisan ngrok

Expected behavior
A ngrok tunnel

ngrok: not found

  • PHP Version: 8.2.5
  • Laravel Framework Version: 10
  • Ngrok Version: 3

Describe the bug
When write sail artisan ngrock the output: sh: 1: exec: ngrok: not found

To Reproduce
Steps to reproduce the behavior:
When write sail artisan ngrock the output: sh: 1: exec: ngrok: not found

Expected behavior
A clear and concise description of what you expected to happen.

Additional context
image

Replace default address localhost for Docker container

Describe the solution you'd like
Option --host-header (bool). To install custom address (container name if use docker) without host-header. Simply put, replacing the default localhost

current

public function buildProcess(string $host = '', string $port = '80') : Process
{
    $command = ['ngrok', 'http', '--log', 'stdout'];

    if ($host !== '') {
        $command[] = '--host-header';
        $command[] = $host;
    }

    $command[] = $port ?: 80;

    return new Process($command, $this->getWorkingDirectory(), null, null, null);
}

feature

public function buildProcess(string $host = '', string $port = '80', $hostHeader = false) : Process
{
    $command = ['ngrok', 'http', '--log', 'stdout'];

    if ($host !== '' && !$hostHeader) {
        $command[] = '--host-header';
        $command[] = $host;
        $command[] = $port;
    } elseif ($host !== '' && $hostHeader) {
        $command[] = "{$host}:{$port}";
    }

    return new Process($command, $this->getWorkingDirectory(), null, null, null);
}

fix for NgrokCommand

    60    public function handle() : int
    61    {
    62       $host = $this->argument('host');
    63       $port = $this->option('port');
    64       $hostHeader = $this->option('host-header');
    ...
   100       $process = $this->processBuilder->buildProcess($host, $port, (bool) $hostHeader);

Describe alternatives you've considered
As quickly solve conside php artisan ngrok --port={container_name}:{port}. This hack solve my needs

UPD: sorry for my broken english

Support for new ngrok domains

Is your feature request related to a problem? Please describe.
In this blog post from the 6th of April 2023, the Ngrok team announced that they will be rolling out new domains. Technically, the ngrok.io base domain is still available for old accounts, but not for free tier users as far as I can see.

Applications of free users will be served from these domains:

  • ngrok-free.app
  • ngrok-free.dev

While applications of paid users will be served from these:

  • ngrok.app
  • ngrok.dev

Describe the solution you'd like
I think the way of determining ngrok host in NgrokServiceProvider needs to be changed. Probably other parts of the codebase will also need to be adjusted.

Describe alternatives you've considered
I tried to force ngrok.io domain using --hostname option, but this feature is only available for paid users.

Additional context
New domain

Custom hostname not allowed

sh: 1: exec: ngrok: not found

  • Version: #.#.#
  • PHP Version: 7.4
  • Laravel Framework Version: 7.4
  • Ngrok Version: 2

Describe the bug
A clear and concise description of what the bug is.
when type php artisan ngrok i got this response "sh: 1: exec: ngrok: not found"

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Additional context
Add any other context or screenshots about the problem here.

Failed to complete tunnel connection (using in Docker container)

  • Version: 0.0.3
  • PHP Version: 7.1
  • Laravel Framework Version: 5.6
  • Ngrok Version: 2.3.27

Describe the bug
Error message when I try to connect to ngrok URL:
image

To Reproduce
Steps to reproduce the behavior:

  1. Go to project folder in Docker container (https://github.com/laradock/laradock in my case)
  2. Run php artisan ngrok
  3. Go in browser to *.ngrok.io.
  4. See error

Expected behavior
Want to see my site with loaded assets (css, js).

Additional context
I try your library in figth with this problem:
https://stackoverflow.com/questions/50194923/laravel-and-ngrok-url-domain-is-not-correct-for-routes-and-assets

Usually I use ngrok http -host-header=myproject.dev 80 command in host machine (not in Docker). I have correct redirects in hosts file.

Error Url pagination

url in pagination error,

use 000000.ngrok.io

in url pagination my-domain-local.com/users?page=1

--port param doesnt work

  • Version: #.#.#
  • PHP Version: 8.1.1
  • Laravel Framework Version: 9
  • Ngrok Version: 3.1.0

Describe the bug
It runs on 4040 port even If I'm putting there port=8000
I'm running this command php artisan ngrok --port=8000 and it's returning

   GuzzleHttp\Exception\ConnectException 

  cURL error 7: Recv failure: Connection reset by peer (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://127.0.0.1:4040/api/tunnels

Enhance to work with Vite and hmr

Is your feature request related to a problem? Please describe.
This works when not running Vite. This would be such a useful feature if it can be also expanded to make it work with Vite and its hot module replacement (hmr) even when using ngrok.

Describe the solution you'd like
Aaron Francis did this in a YouTube video, but I could not make it work following the video.
https://youtu.be/pT7e31DMTYY

Thank you very much for this project. It has been incredibly helpful.

The package doesn't allow for the setup of an ngrok auth token and doesn't handle errors if the token is not set

  • Version: 2.0
  • PHP Version: 7.4
  • Laravel Framework Version: 8.36
  • Ngrok Version: 3.2.2

Describe the bug
I got error in console after php artisan ngrok loc-team.test:
cURL error 7: Send failure: Connection was reset (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://127.0.0.1:4041/api/tunne

After some research i figured out, that this error appears because ngrok just did not started properly. And it's because it wanted me to set auth token (with command ngrok config add-authtoken).

The ngrok token you can get at https://dashboard.ngrok.com/get-started/setup

To solve the problem in the NgrokProcessBuilder.php file i added one line:
$command = explode(" ", "ngrok config add-authtoken XXXXXXXXXXX");
before
return new Process($command, $this->getWorkingDirectory(), null, null, null);
And commented out if block with $tunnels = $webService->getTunnels(); in the NgrokCommand.php

This changes i made only for one request CLI command - php artisan ngrok

I am not able to launch 2 tunnels configured in ngrok.yml config file

  • Version: #.#.#
  • PHP Version:7.4
  • Laravel Framework Version:8
  • Ngrok Version:3.3

Describe the bug
When we run command PHP artisan ngrok we pass --extra parameter with config file path. Where I've written 2 tunnels. But after running PHP artisan ngrok command both the tunnels are not starting. Its starting only single tunnel.

Please see below information


| NGROK |

Host header: localhost
Host: localhost
Port: 80
Extra: --config=/home/skodilkar/snap/ngrok/108/.config/ngrok/ngrok.yml

Web Interface: http://127.0.0.1:4040

Forwarding: https://4110-115-160-208-226.ngrok-free.app -> http://localhost:80 <<< ONLY 2 tunnel is starting not the second one

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.