Skip to content

Instantly share code, notes, and snippets.

@janstuemmel
Last active January 27, 2019 17:12
Show Gist options
  • Save janstuemmel/245b5bba5b5247df5617473ab31582a8 to your computer and use it in GitHub Desktop.
Save janstuemmel/245b5bba5b5247df5617473ab31582a8 to your computer and use it in GitHub Desktop.
SSH reverse prox for web development

SSH Reverse Proxy

ssh -nN -R <remote-port>:localhost:<local-port> <username>@<server-ip-or-hostname>

Explanation

  • <remote-port> Any free port on your remote server, e.g. 9999
  • <local-port> The port your local webserver is listening to, e.g. 8080
  • <server-ip-or-hostname> Your remote server's hostname or ip, e.g. example.com
  • <username> A user on the remote server, e.g. foo
  • -R Arg for reverse proxy
  • -n Prevens reading from STDIN
  • -N Prevents executing remote commands

Example

Let's say your development server is running on 8080, for example with Python: python -m SimpleHTTPServer 8080 (serves working directory contents). To access contens from the internet on http://example.com:9999 type...

ssh -nN -R 9999:localhost:8080 foo@example.com

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment