How we move traffic between our servers without exposing it to the Internet

Published on 2026-09-12 by frfrand

When an app on a server needs a database that lives on another, there are two paths: open a port to the world or make them see each other. Why we chose the second.

How we move traffic between our servers without exposing it to the Internet

Short answer: when an app on an ArduMaker VPS needs a database that lives on another VPS, you don't open the database port to the Internet: you set up an SSH tunnel initiated by the app server toward the database server. The app sees the database on localhost, the database port is never published, and the only thing exposed on the data side is a dedicated SSH port that only accepts authorized keys.

It's one of the most common situations as soon as a project grows a bit: the application runs on one server and the database on another. How do they talk to each other?

The quick answer is to open the database port and point the app to the other server's public IP. It works in five minutes. And it leaves a database exposed to the Internet, which is exactly what you spend the following years trying to avoid.

We solve it the other way around.

The problem with the easy solution

Opening port 5432 to the world has three costs that you don't see on day one:

  • The database ends up on automatic scanner lists within minutes.
  • Security ends up depending on the database password and on its version not having vulnerabilities. Forever.
  • Traffic between your two servers travels over the public network with whatever protection the database protocol provides, which is often none if you didn't configure TLS.

That last point is underestimated: queries and results, with your users' data, crossing networks you don't control.

What we do instead

Among ArduMaker VPSs, internal traffic travels through SSH tunnels between the machines. From the application's point of view, the database is on localhost, on the port you choose. From the Internet's point of view, the database server has no database port open.

The important part is the address where the tunnel is raised: it is started by the side that needs to connect, the application side. The server that stores the data accepts only one thing: SSH connections to a dedicated port, with a tunnel user that is good for nothing else and that only accepts the keys you authorized. The database door does not exist; the one that remains is small, encrypted, and with one key per machine.

How it looks in practice

Configuration is done from the panel (or with the MCP tool configurar_tunel_entre_vps): one VPS remains as receiver, the other as initiator, the initiator's public key is authorized on the receiver, and it is defined which local port of the initiator leads to which port on the other side. The initiator maintains the connection with autossh and rearms itself alone if it is cut. From there on:

# on the app server, the database is local DATABASE_URL=postgres://usuario:clave@localhost:5432/midb

Your application's connection string points to localhost. If tomorrow the database moves to another server, change the tunnel configuration and the application won't notice.

That decoupling is half the value. The other half is that the exposed surface does not grow as your infrastructure grows.

What else you gain

Less duplicated configuration. You don't have to maintain firewall rules for every pair of servers that talk to each other.

Reversible. Removing the key from an initiator cuts its access to that server without affecting the others, and uninstalling the receiver deletes its tunnel user and its SSH configuration.

Auditable. The tunnel is a platform object, with its state, and the additions and removals of receivers and keys are recorded in the VPS activity log. You can answer "who can talk to this database?" by looking at a list, instead of reconstructing it from iptables rules.

Your own keys. The receiver accepts only the keys you declared. Adding a new server means adding its key, and removing it means deleting it.

When it's not enough

If what you need is for a third-party service to reach your database (an externally hosted analysis tool, for example), a tunnel between your servers doesn't solve that. There, the options are a VPN that includes that third party, a read-only replica designed to be exposed, or your own API that returns only what that third party needs.

The third option is usually the best, even though it takes more work: it's the only one where you decide exactly what goes out.

The underlying idea

It's the same one that runs throughout the platform: what doesn't need to be open, isn't opened. And when two things need to talk to each other, it's better to make them see each other than to make them visible to everyone.

Separate internal traffic from public traffic

When an application hosted on ArduMaker queries a database located on another server, communication can be designed through internal routes and authorized tunnels. It is not necessary for the database to listen publicly just because the backend is separate.

Before deploying, define which service initiates the connection, how it authenticates, what happens if the tunnel is interrupted, and where errors are observed. Ensure that network rules and the engine service reject connections from outside allowed origins.

Related: Port forwarding · What is a subnet.

Frequently asked questions

Is the tunnel between VPSs a VPN? No. It is a point-to-point SSH tunnel (a permanent ssh -L): it carries a specific port from one server to another, it does not join entire networks.

What happens if the tunnel drops? The initiator brings it back up automatically with autossh. While it is down, the app cannot reach the database, so it is advisable to handle that error and retry.

Can I limit which IP can reach the receiver? Yes. The receiver's SSH port is a forwarding from the VPS, and source IP policies can be applied to forwardings.

Is it useful for an external service to read my database? No: for a third party it is better to use a dedicated API that returns only what is necessary, a read-only replica, or a VPN that includes it.

  • ArduMaker
  • túneles
  • redes internas
  • seguridad
  • infraestructura

Keep reading

All articles · VPS plans