This project allows you to access an application running on localhost from a remote URL.
This is useful for testing integrations that cannot access localhost and need an application running in the cloud.
If you've used ngrok, it works the same way, but with a little more control.
git clone https://github.com/GiovanniCavallari/nginx-proxy.git
bash bin/run HOST_PORT TUNNEL_PORT TUNNEL_PATH CONTAINER_NAME
Params explained:
- HOST_PORT is the port to receive browser requests on host.
- TUNNEL_PORT is the port that will be used to redirect browser requests to localhost.
- TUNNEL_PATH is the path you will access to redirect to your localhost.
- CONTAINER_NAME is the container name to make docker cli easy to use.
Start some sample app for the proxy tunnel to access your localhost and return the content. For example, some app using express.
ssh -nN -R TUNNEL_PORT:localhost:LOCALHOST_APP_PORT username@yourdomain.com
Ports explained:
- TUNNEL_PORT is the forwarded port on the host that we use to directly SSH into the container.
- LOCALHOST_APP_PORT refers to the port that your app is running on localhost.
As long as you keep this SSH connection open, you'll be able to access your app from either:
The SSL Certificate is generated by https://certbot.eff.org.
bash bin/setup-ssl DOMAIN_NAME EMAIL CONTAINER
Params explained:
- DOMAIN_NAME is the domain name to certbot validate and generate a SSL Certificate.
- EMAIL is the email that CA will send notification emails to the address you provide if you do not renew certificates that are about to expire.
- CONTAINER is the container name or container id.
As long as you keep this SSH connection open, you'll be able to access your app from https://dev.app.com.
Run the script to create and setup a new rule on nginx:
bash bin/setup-rule RULE_NAME TUNNEL_PATH TUNNEL_PORT CONTAINER
Note: if a RULE_NAME that already exists is set, the old rule will be overwritten
Params explained:
- RULE_NAME is the name used to create a file for the rule.
- TUNNEL_PATH is the path you will access to redirect to your localhost.
- TUNNEL_PORT is the port that will be used to redirect browser requests to localhost.
- CONTAINER is the container name or container id.