The ngrocker, is a docker project using docker-compose and source code of ngrok 1.x to easily run the ngrok-server and ngrok-client.
The images of this project together has less of 35 MB.
The focus of this project is the ngrok sniffer tool with locally HTTP tunnels.
- Small, it uses alpine image and multi-stage build;
- Simple, this project was made to be easy as the original ngrok server;
- Sniffer, the focus of this project is the ngrok sniffer tool, so the updates will focus on improving it. Some improvements are already available, like requests search and colored methods and status.
- Use script to easily configure and up the containers, or
- Configure
.env
file and use docker-compose to run.
Using script ↑
This script has been tested only on Ubuntu 16.04 LTS, but your code not have any ubuntu exclusive code.
First, you need clone this repository, access your folder and execute the script:
$ git clone https://github.com/magicred7/ngrocker.git
$ cd ngrocker
$ ./ngrocker
The script will show all available commands. To link the ngrocker into your system, run:
$ ./ngrocker -l
Now you can run ngrocker
from anywhere. See the help
of the script for more information.
This script is an automation of "Using docker-compose". I recommend you read it to better understand its operation.
# To make a tunnel of the nginx running into your port 80 to localhost:81.
$ ngrocker -h localhost:80 -t localhost:81
# To make a tunnel of the nginx container to localhost:80.
# Note if your nginx expose the port 80, if yes, you tunnel
# has to run on another port.
$ ngrocker -c nginx
# To make a tunnel of the your website into localhost:80.
# Your website needs to be HTTP. HTTPS not work yet.
$ ngrocker -h your-website.com
######### SOME EXAMPLES #########
$ ngrocker -c laradock_nginx_1 -t my-etc-host-site.com:81
$ ngrocker -h localhost:80 -t localhost:81 -i 82
$ ngrocker -n laradock_frontend -c nginx -t localhost:81
Using docker-compose ↑
Clone this repository, access your folder and create a .env
file. If you want, you can just clone the env-example
file and change the name:
$ git clone https://github.com/magicred7/ngrocker.git
$ cd ngrocker
$ mv env-example .env
Now configure your .env file and up the images with docker-compose:
$ docker-compose up -d
If you want run just the ngrok server, execute:
$ docker-compose up -d ngrok-server
Now you have the ngrok-server and ngrok-client (if you want), running into your machine!
There are two ways to use the ngrocker.
is making a tunnel of other container. To make this, you need to define a docker network (or using a pre-defined network) and use the container hostname or your ip, to make an internal tunnel. After that, the defined http port is going to show the container content. The tunnel will be working.
You just need create a docker network (or use one) and configure the other container to use them. On the ngrok, you just modify your .env file like this:
NGROK_NETWORK_NAME= <shared_network_name>
NGROK_TARGET_ADDRESS= <container_hostname>:<container_port>
NGROK_TUNNEL_ADDRESS= <tunnel_address>
Example:
If you want create a Laradock Nginx's tunnel, the Laradock Project, already make a network called laradock_frontend. Just use it, the hostname of the nginx (called nginx too) and the http port:
NGROK_HTTP_PORT=81
NGROK_NETWORK_NAME=laradock_frontend
NGROK_TARGET_ADDRESS=nginx:80
NGROK_TUNNEL_ADDRESS=localhost
I changed the ngrok's http port to 81, because the nginx are running into this port too. The tunnel address can be other address configured into nginx too.
Now you can access then, into your host machine with address localhost:81
.
is configuring the client to make a host tunnel. The configuration is the same, but where you set the hostname of the docker container, you will put the IP address of your host.
Example, if your IP is 172.26.0.2
:
NGROK_HTTP_PORT=81
NGROK_TARGET_ADDRESS=172.26.0.2:80
NGROK_TUNNEL_ADDRESS=localhost
But, if you want use modified names, then use the DNS to define the server will resolve this names:
NGROK_HTTP_PORT=80
NGROK_NETWORK_DNS=172.26.0.1
NGROK_TARGET_ADDRESS=my-resolved-name.com:80
NGROK_TUNNEL_ADDRESS=localhost
Now you can access then, into your host machine with address localhost:80
.
IMPORTANT: If you change the .env
file, you must restart the containers for the new settings to work.
If you want use nginx, just set the name of website into NGROK_TUNNEL_ADDRESS
:
NGROK_TUNNEL_ADDRESS=my-local-website.com
After this, access this site with the ngrok's http port, like my-local-website.com:81
.
Default Ports ↑
- 4443, to ngrok server;
- 443, to https tunnel (disabled, still does not work);
- 80, to http tunnel;
- 4040, to ngrok inspector;
Details ↑
- Created and maintained by Emerson C. Romaneli (@magicred7).
- @mateusvtt For helping with docker;
- @inconshreveable For sharing the code of ngrok 1.x.
- ngrok 1.x fork The images of this project uses this. All updates focus improvements on sniffer tool;
- ngrok 1.x original The original repository.
This project (ngrocker) dont focus security, please dont use this for this purpose.
ngrok's original repository message:
DO NOT RUN THIS VERSION OF NGROK (1.X) IN PRODUCTION. Both the client and server are known to have serious reliability issues including memory and file descriptor leaks as well as crashes. There is also no HA story as the server is a SPOF. You are advised to run 2.0 for any production quality system.