Skip to content

Recipes

Each recipe here is a job readers actually hand NPM, stated as an outcome with its check. Every step uses machinery a previous chapter built; nothing new is introduced without naming it.

A home service on its own name

Job: the service on 192.168.1.50:8080 answers at app.example.com from anywhere.

  1. Point app.example.com at your machine in DNS, and forward ports 80 and 443 (not 81) at your router to the NPM machine.
  2. Add a proxy host: name app.example.com, scheme http, forward host 192.168.1.50, port 8080, Block Common Exploits on.
  3. On its SSL tab, request a certificate with Force SSL on.
  4. Check: from your phone with Wi-Fi off, https://app.example.com loads the service, and the padlock shows a certificate for the name.

HTTPS forced, start to finish

Job: an older service with its own login gets HTTPS on the public side while staying plain HTTP at home.

The shape chapter 5's form already implies: the forward scheme stays http (NPM-to-service, on your LAN), and the certificate works the public side. On the SSL tab: attach the certificate, Force SSL on, HTTP/2 on, HSTS on once you are committed. Check: curl -sI http://app.example.com returns a 301 to the https address, and the service's own logs show requests arriving from the NPM machine — the hop behind NPM is the plain one, by design.

A password gate in front of a naked service

Job: a dashboard with no login of its own stops being open to the neighbourhood.

Follow chapter 10: create an access list with one username/password pair and Allow only your LAN range with deny-by-default — Satisfy Any off — and attach it to the host. Check the chapter's three codes (403 from outside the rule, 401 without credentials, the service itself with them). Remember the recipe's limit: basic auth travels safely only over HTTPS, so pair this with the previous recipe before using it from outside the house.

The WebSocket switch, when a page will not update

Job: a service whose page needs live updates (chats, dashboards, terminals) loads but never refreshes, or errors about a failed upgrade.

Edit the proxy host and turn on Websockets Support. Behind the switch, NPM adds the upgrade headers (Upgrade / Connection) to the generated location — the one piece of chapter 6's proxy.conf story the default omits. Check: the page updates live, and the host's file in /data/nginx/proxy_host/ shows the extra headers, proving — as always — that the file, not the form, is what changed.

One awkward path, handled by a custom location

Job: everything proxies to the service except /files/, which lives on a different machine.

On the proxy host's Custom Locations tab, add a location: define location /files/, forward host and port of the other machine. NPM writes it as an additional location block inside the same generated server — read it there afterwards (chapter 6) to see exactly what you ordered. Check: curl -s https://app.example.com/files/ answers from the second machine while / still answers from the first.

Retiring a name gracefully

Job: a service is gone, but its name still gets visitors.

Do not delete the proxy host and leave the name to fall through. Replace it: delete the proxy host, create a dead host (chapter 9) for the same name, and every visitor gets the same clean 404 with nothing behind it. If the name moved rather than died, a redirection host to the new address is the kinder ending. Check: the name answers exactly the ending you chose — and dig still points it at you, so the ending stays yours to change.