Port forwarding: what it is and what it solves
Published on 2026-09-12 by frfrand
What port forwarding actually does, how it differs from a reverse proxy and an SSH tunnel, and when each one is the right tool.

Short answer: "port forwarding" is used for three distinct mechanisms: router NAT forwarding (rewrites addresses without understanding what travels), reverse proxy (understands HTTP and distributes by domain; it is the right choice for web traffic) and SSH tunnel (brings a remote port to your machine over an encrypted channel; it is the right choice for one-off access to a database). To choose, ask yourself whether the service needs to be open to the world or only to you.
"Port forwarding" sounds like one thing and is actually used for three distinct mechanisms that are worth separating, because they are chosen at different times.
In all of them, the underlying idea is the same: something arrives at a door and is delivered at another, which may be on another machine.
1. Router forwarding (NAT)
It is the classic home network scenario. Your router has a public IP; the machines inside have private addresses that the Internet cannot reach.
A forwarding tells the router: "everything that arrives at port 8080 of my public IP, send it to port 80 of machine 192.168.1.50".
It works at the network layer: the router rewrites the destination address of the packet. It does not understand anything about what travels inside.
It is what is used to expose a game console, a camera, or a home server. And it is also the easiest way to leave something exposed unintentionally, because the router does not validate anything that passes through.
2. Reverse proxy
Here the intermediary actually understands what it transports. nginx receives an HTTPS request on port 443 and decides, based on the domain and path, which internal application to send it to.
server { server_name api.miempresa.com; location / { proxy_pass http://127.0.0.1:3000; } }
The important difference: since it speaks HTTP, it can distribute by domain (multiple sites on the same server), terminate TLS, cache, compress, limit requests, and add headers. A router forwarding cannot do any of that.
If what you're moving is web traffic, you almost always want a reverse proxy and not just plain forwarding.
3. The SSH tunnel
The most underestimated of the three, and the one that solves the most problems in day-to-day work.
ssh -L 5432:localhost:5432 prod
This makes port 5432 on the server appear as if it were local on your machine. Your database client connects to localhost and the traffic travels encrypted via SSH.
The great advantage: the database does not need to be open to the Internet. No exposed port, no automatic scanner to find it, and access is tied to your SSH key.
There is also the reverse version (-R), which publishes a port from your machine on the server. Useful for showing someone something running on your laptop.
Which one to use
- Web traffic, with domains and certificates? Reverse proxy.
- Occasional access from you to an internal service (database, panel, Redis)? SSH tunnel.
- A protocol that isn't HTTP and really needs to be public? Then yes, port forwarding, with a tightly configured firewall.
The question that guides the decision: does this need to be open to the world, or only to you? If the answer is "to me", don't open a port: create a tunnel.
How it's solved in ArduMaker
Between two ArduMaker VPSs you can set up a permanent SSH tunnel: one VPS acts as the initiator (the one that needs to connect) and the other as the receiver. The initiator maintains the connection with autossh and sees the service on the other side on a local port, so an app on one server can consume a database that lives on another without that database's port ever being published. All the receiver publishes is a dedicated SSH port, with a tunnel user that only accepts the keys you authorized, and the traffic travels encrypted.
It's the same principle behind the whole system: what doesn't need to be open, isn't opened.
Choosing the right mechanism when deploying
In ArduMaker, a common case is publishing an API with a domain and HTTPS while the process listens on an internal port. For HTTP traffic, a reverse proxy allows routing by domain name, managing certificates, and observing upstream errors.
To connect to PostgreSQL from your computer on a one-off basis, an SSH tunnel avoids having to open the database port to the Internet. Use pure port forwarding when the protocol and design require it, not out of habit.
Related: What is Nginx · PostgreSQL without exposure.
Frequently asked questions
What is the difference between port forwarding and a reverse proxy? Port forwarding changes the destination address of the packet without looking at the content. The reverse proxy speaks HTTP: it can choose the app based on the domain, terminate TLS, cache, and limit requests.
What does ssh -L 5432:localhost:5432 server do? It makes port 5432 on the server appear on port 5432 on your machine, through the encrypted SSH connection. The database does not need to be open to the Internet.
What is ssh -R for? It is the reverse path: it publishes a port from your machine on the server, for example to show someone something running on your laptop.