Reach a Home Service from Your Laptop

A service on a machine at home becomes a local port on your laptop, wherever the laptop is. The home machine opens no port and gets no public link: only machines of your account reach it.


Goal

On the laptop, curl http://127.0.0.1:18080/ reaches a web app on port 8080 of home-server, a machine at home.

Prerequisites

1. A service at home

On home-server, use your own service on any port. This tutorial serves one page on port 8080:

$ echo 'hello from home' > index.html
$ python3 -u -m http.server 8080
Serving HTTP on :: port 8080 (http://[::]:8080/) ...

2. Serve it

On home-server, in a second terminal, serve port 8080 as the service web:

$ nfltr cat serve web --forward localhost:8080
Connected — waiting for requests... (press Ctrl+C to stop)
SERVICE  TYPE  AGENT            ACCESS                                                               NOTE
web      tcp   home-server/web  nfltr cat forward home-server/web --listen 127.0.0.1:<local-port>  the relay can read this

It runs until you stop it. It opens no port: it holds one connection out to the relay, and dials localhost:8080 only for a session that comes from a machine of your account.

3. Connect from the laptop

On the laptop, nfltr cat forward turns the service into a local port. Another machine names it <machine>.<agent>/<service>, and the agent is the serving machine's name:

$ nfltr cat forward home-server.home-server/web --listen 127.0.0.1:18080
connect forward: listening -> home-server.home-server/web on 127.0.0.1:18080
$ curl -s http://127.0.0.1:18080/
hello from home

A browser, ssh, psql or any TCP client uses the local port the same way. The port stays open while home-server is offline; a connection made then is closed at once, and the next one after it is back goes through.

This session goes through the relay, which can read it (the table's note says so). To keep the relay out of it, put both machines in an organisation and serve with --allow-group: the session is then end to end encrypted between the two machines.

4. Clean up

Press Ctrl+C in the nfltr cat forward terminal on the laptop, then in the nfltr cat serve terminal on home-server, then stop the web server.

# Ctrl+C in the nfltr cat forward terminal
# Ctrl+C in the nfltr cat serve terminal

Next