Skip to content
VpnHood!

Reach your server through a relay

When a firewall blocks the road from your users to your server, a relay on their side of it can carry the connection. The apps connect to the relay, and it passes everything on to your server without opening it.

How a relay works

Your users can reach your server in two ways: straight at its own address, or through a relay. The relay can be any machine on their side of the firewall that can still reach your server, for whatever reason: it may have a privilege, or a path where the usual restrictions don't apply, such as a data center network that the firewall lets through. Your users reach it like any local server, and it forwards one port on to your server.

Straight to your server, or through a relay Straight to your server's address is blocked at the firewall. The relay, on the users' side, takes the tunnel through a gate the firewall leaves open for it. Firewall Straight to your server Blocked The relay's address 198.51.100.40 Passed on 203.0.113.10 Your users Phones and computers Your server VpnHood! SERVER Relay Has a way through the firewall The firewall leaves a gate open for the relay
Straight to your server, or through a relay Straight to your server's address is blocked at the firewall. The relay, on the users' side, takes the tunnel through a gate the firewall leaves open for it. Firewall Straight to your server Blocked The relay's address 198.51.100.40 Passed on 203.0.113.10 Your users Phones and computers Relay Has a way through the firewall Your server VpnHood! SERVER The firewall leaves a gate open for the relay

The relay can't read the tunnel, which is encrypted from the app to your server. It sees which addresses connect to it and how much they send, and your server sees the relay's address in place of your users'.

A proxy in the relay's place

A proxy is another way to build the relay: the machine runs a SOCKS or HTTP proxy instead of forwarding a port, and the app reaches your server through it, as through any of its proxies. Both can run on the same machine. But a proxy has drawbacks that a relay doesn't:

  • The request of a SOCKS or plain HTTP proxy names your server's address in plain text, so anyone on the way to the proxy can read where your users connect, and block it.
  • The app sends the tunnel through a proxy over TCP only, whatever the Tunnel protocol setting, even when the proxy could carry UDP. A relay passes UDP on as well.
  • Each user has to add the proxy to their app, while a relay's address can travel in their keys.
A proxy in the relay's place Straight to your server's address is blocked at the firewall. A proxy on the users' side goes through the same open gate, but its request names your server, so anyone on the way can read it and block it. Firewall Straight to your server Blocked Read on the way 203.0.113.10 Passed on 203.0.113.10 Your users Phones and computers Your server VpnHood! SERVER SOCKS or HTTP proxy Has a way through the firewall A proxy gets through too, but can be read and blocked
A proxy in the relay's place Straight to your server's address is blocked at the firewall. A proxy on the users' side goes through the same open gate, but its request names your server, so anyone on the way can read it and block it. Firewall Straight to your server Blocked Read on the way 203.0.113.10 Passed on 203.0.113.10 Your users Phones and computers SOCKS or HTTP proxy Has a way through the firewall Your server VpnHood! SERVER A proxy gets through too, but can be read and blocked

A relay asks for nothing. Your users connect to it as they would to your server, so anyone on the way sees only the tunnel.

A relay on a satellite link

A relay whose own internet comes over a satellite link, such as Starlink, needs no way through the firewall: its traffic goes up to the satellite and down to your server, and never meets the firewall. Your users reach the relay over the local network.

A relay that sends the tunnels over a satellite link Straight to your server's address is blocked at the firewall. The users reach the relay over the local network, and the relay sends their tunnels up to a satellite and down to your server, over the firewall. Firewall Local network Straight to your server Blocked Satellite link Your users Phones and computers Relay With a satellite dish Your server VpnHood! SERVER The satellite link never meets the firewall
A relay that sends the tunnels over a satellite link Straight to your server's address is blocked at the firewall. The users reach the relay over the local network, and the relay sends their tunnels up to a satellite and down to your server, over the firewall. Firewall Local network Straight to your server Blocked Satellite link Your users Relay With a satellite dish Your server The satellite link never meets the firewall

Set up the relay

Choose a machine on your users' side of the firewall that can reach your server and has port 443 free. The relay's installer is for Linux with systemd, such as Ubuntu and Debian. A router can be the relay too, by forwarding the port in its own settings.

On that machine, run the relay's installer. Put your server's address in place of 203.0.113.10:

sudo bash -c 'u=https://github.com/vpnhood/VpnHood.App.Server/releases/latest/download/VpnHoodServer-linux-relay.sh; s=$(wget -qO- $u 2>/dev/null) || s=$(curl -fsSL $u) && bash -c "$s" -- -server 203.0.113.10'

The relay starts at once, and again after every restart. It passes on TCP and UDP on port 443, only what is sent to the relay itself, so the machine's other traffic is left as it was. It works beside a firewall such as ufw, and beside Docker.

If your server uses another port, add -port and that port. The relay then takes it too.

To see the relay, turn it off or on again, or remove it:

sudo vhrelay status
sudo vhrelay disable
sudo vhrelay enable
sudo vhrelay uninstall

Give your users the relay's address

There are three ways, and you can use them side by side.

In the access keys

Your keys can carry the relay's address beside your server's own. Each app connects through whichever of them answers, so users who can reach your server directly still can.

An access key with two addresses The key carries your server's address and the relay's. Where the firewall blocks your server's address, the app connects through the relay, which goes through the gate the firewall leaves open. Firewall Access key Your server's address 203.0.113.10 The relay's address 198.51.100.40 Relay Your server The app connects through whichever answers
An access key with two addresses The key carries your server's address and the relay's. Where the firewall blocks your server's address, the app connects through the relay, which goes through the gate the firewall leaves open. Firewall Access key Your server's address 203.0.113.10 The relay's address 198.51.100.40 Relay Your server The app connects through whichever answers

On a standalone server, add the relay's address to PublicEndPoints, as Set your server's IP addresses shows, keep your server's own address there too, and restart the server.

Keys you have already given out get the relay's address the next time their app connects to your server. An app that can no longer reach your server needs a new key from you.

With a domain name

If your keys carry a domain name, point the name at the relay: put the relay's address in its DNS record. The apps look the name up and connect to the address it gives, so you can move to another relay later by changing the record, with no new keys.

A domain name that leads to the relay The key carries a domain name, and its DNS record gives the relay's address. server1.example.com 198.51.100.40 Access key Carries a domain name DNS record Points at the relay Relay Change the record, and every key follows
A domain name that leads to the relay The key carries a domain name, and its DNS record gives the relay's address. server1.example.com 198.51.100.40 Access key Carries a domain name DNS record Points at the relay Relay Change the record, and every key follows

Typed in by a user

A user can also enter the relay's address in the app, with no change to the keys. In the server list, they open the server's menu, choose Custom server address, turn on Use custom server address, and enter the relay's address and port. Only the users you tell use the relay.

The relay's address typed into the app A user enters the relay's address and port as the server's custom address, and the app connects to the relay. Custom server address198.51.100.40:443 The app Relay The key stays as it is
The relay's address typed into the app A user enters the relay's address and port as the server's custom address, and the app connects to the relay. The app Custom server address198.51.100.40:443 Relay The key stays as it is

Next steps