Reverse Proxy and SSH Tunneling

Last modified by Eleni Cojocariu on 2026/05/13 19:33

Explanation

Warning

WIP

Proxying combined with SSH tunneling allows a remote server to forward incoming traffic to a service running on a local machine. This is useful when the local service is not directly accessible from the internet due to for example firewall restrictions, dynamic IP addresses. In this setup, a reverse SSH tunnel is created from the local machine to a remote server. The tunnel maps a port on the remote server (for example, 8080) to a port on the local machine where the application is running (for example, 127.0.0.1:8080). As a result, any request received by the remote server on the mapped port is securely forwarded through the SSH connection to the local service.

A reverse proxy such as Nginx can then be configured on the remote server to expose the service under a public domain (for example, https://wiki.yourdomain.com). The proxy forwards incoming HTTP requests to the locally tunneled port, making the locally running application accessible as if it were hosted on the remote server.

This approach is commonly used for development, testing, and temporary deployments. It eliminates the need for the local machine to have a public IP address or direct inbound network access, while still allowing external users to access the service securely through the remote server.

FAQ

How can I verify that the remote port is available?

Before creating the reverse SSH tunnel, make sure that port 8080 is not already in use on the remote server. Run the following command from your local machine:

ssh server wget -O - http://127.0.0.1:8080/. Expected result: Connection refused

What if another service is already listening on port 8080 on the remote server?

If the command returns a web page or another response instead, it means that another service is already listening on port 8080 on the remote server. In this case, either:

  • stop the conflicting service, or
  • use another port for the SSH tunnel.

For example: ssh -R9090:127.0.0.1:8080 server. This exposes the local XWiki instance through port 9090 on the remote server instead of 8080.

Get Connected