On-demand tunnels
Procy opens tunnels only when you ask for one and closes them when they are idle. This page explains how that works and what a self-hosted server needs for it. On hosted Procy it works out of the box: install the client and create a tunnel.
- The client connects out to the server and keeps that one connection open. No port is open on the server for it yet, and nothing is open on the client’s network.
- You request a tunnel in the web interface or through the API.
- The server opens a port from its tunnel range and tells the client, over the existing connection, which port on the device (or on a host the device can reach) to forward to.
- You connect to the server port. Only the addresses in the tunnel’s access list get through.
- When the tunnel has been idle for its timeout (5 minutes by default), or its fixed lifetime ends, the server closes it and the port is free again.
Compared with tunnels the client opens at start (remotes in rport.conf), on-demand tunnels keep nothing exposed
while nobody is working on a device, and you choose who may connect each time.
Self-hosted only.
- The API. Tunnels are requested through the API, so
[api] addressmust be set inrportd.conf(the web interface uses the same API). See the quick start and the web interface. - A tunnel port range that clients can be reached on from where you work.
used_portsin[server]sets the range (default20000-30000), andexcluded_portsremoves ports from it (default1-1024). Open that range in the server’s firewall for the addresses you connect from. - A tunnel host, if the API sits behind a reverse proxy that can’t pass raw TCP. Set
[server] tunnel_hostto a name that reachesrportddirectly; links and connect commands for tunnels then use it.
[server]
used_ports = ['20000-30000']
excluded_ports = ['1-1024']
#tunnel_host = "tunnels.procy.example.com"
Check the server with curl -s -u admin:$PASSWORD https://procy.example.com/api/v1/status | jq. The response has a
capabilities object that lists the features this server offers, for example "port_tunnels": true and
"http_proxy_tunnels": false. The web interface hides what is not available.
A client installed by the Procy installer connects without tunnels and waits. If you configure a client by hand,
leave remotes unset in rport.conf, or start it without a tunnel argument:
rport --auth client1:<CLIENT_PASSWORD> --fingerprint <FINGERPRINT> procy.example.com:8080
The client shows up as connected, with no tunnels. Open one when you need it, as described in managing tunnels.
Self-hosted only. rportd runs as an unprivileged user, and you should keep it that way. Unprivileged users can’t
open ports below 1024, but you can give the rportd binary the capability to do so:
sudo setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/rportd
Now you can use 0.0.0.0:443 as the API address. Run the command again every time the rportd binary changes, for
example after each update.