Giter VIP home page Giter VIP logo

port-forwarding's Introduction

Publish ports on a remote host

Having troubles testing pushes/pixels/callbacks queried from external services with all your code running on localhost?

This example shows how to publish ports on a remote host with ssh server running in docker.

What's inside?

  • Vagrantfile with multiple virtual network interfaces preconfigured. It's here for tests.
  • Dockerfile having ssh server inside for port forwarding/publishing.
  • Bash scripts to create containers and clear unused automatically.

How to use it (soft way)

Copy scripts from bin to your proxy server and get docker running (or just vagrant up if you're playing on localhost). Build docker image, then start server with server-new-agent.sh <port1> <port2> ... specifying ports you want to publish. Start ssh tunnel from your working machine to proxy server.

Clear old containers with server-clear-hanging.sh (just add it to cron).

P.S. Scripts are prepared for a multi-interface machine where you have at least one free interface for ports publishing without any open connections.

How to use it (hard way)

Assuming we want to publish ports on 192.168.50.8. On the server we're starting docker container, exposing ports 22 and 80 on specified interface - 192.168.50.8 (ports 22 and 8080 used inside the container).

Reverse tunneling port 80 from 192.168.50.8 to our local machine with ssh tunnel.

Basically, for tests you'll have to start vagrant with vagrant up, login to it with vagrant ssh, change directory with cd /var/www/sshd/, build docker container inside and start it. When container is ready you can set ssh tunnel and check if all works as it should.

Docker container built from standard how-to on the server side:

# Build container
sudo docker build -t eg_sshd .

Run container:

# Run container with port mappings
sudo docker run -d -p 192.168.50.8:2222:22 -p 192.168.50.8:80:8080 --name test_sshd eg_sshd

SSH tunnel on the client side:

ssh -R 0.0.0.0:8080:localhost:80 -N [email protected] -p 2222

Start docker container, open tunnel, have fun.

port-forwarding's People

Contributors

spectrox 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.