Giter Club home page Giter Club logo

nginx-proxy's Introduction

NGINX Proxy Tunnel

Table of Contents

Description

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.

Diagram

Setup

1. Clone the repository on your instance

git clone https://github.com/GiovanniCavallari/nginx-proxy.git

2. Run the script

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.

3. Start the sample app on localhost

Start some sample app for the proxy tunnel to access your localhost and return the content. For example, some app using express.

4. Open SSH connection

ssh -nN -R TUNNEL_PORT:localhost:LOCALHOST_APP_PORT [email protected]

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.

5. Access the proxy tunnel URL

As long as you keep this SSH connection open, you'll be able to access your app from either:

Setup SSL

The SSL Certificate is generated by https://certbot.eff.org.

1. Run the script

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.

2. Access the proxy tunnel URL

As long as you keep this SSH connection open, you'll be able to access your app from https://dev.app.com.

Setup rule

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.

nginx-proxy's People

Contributors

giovannicavallari avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.