Local service as backend for a public server
Running a local -for example on a PC behind NAT- TCP or UNIX-domain socket service as backend for NGINX on a public web server. This forwards the local socket using reverse SSH.
Base command-line:
ssh -nNT -R {port_on_server}:localhost:{port_of_backend} {user}@{server}
Item | Description | Examples |
---|---|---|
-n | Prevent reading from stdin | |
-N | Do not execute a remote command | |
-T | Do not allocate a TTY (terminal) | |
-R | Establish a reverse connection | |
{port_on_server} | TCP or UNIX domain socket. Needs special permissions for TCP ports 1024 and under | 8080 /tmp/my_service.sock |
localhost | Make a connection locally | |
{port_of_backend} | Port the local service is listening on | 3333 |
{user} | SSH user name | sshuser |
{server} | Server IP or host name | example.com |