Skip to content

Redirection, Dead Hosts and Streams

Proxy hosts are the headliner, but NPM manages three more kinds of host, and the outcome of this chapter is knowing which kind a given job wants. All four share the same machinery — a record, a generated file in its own folder under /data/nginx/, a test and a reload — so everything chapter 6 taught you about reading files transfers.

Redirection hosts answer a name by sending the visitor elsewhere: an old domain to its replacement, a short name to a long one. The form asks for the domain names, the scheme and domain to forward to, whether to preserve the path (so old.example.com/reports lands on new.example.com/reports, not the front page), and the status code — 301 for a permanent move (search engines and browsers remember it) or 302/307 for temporary ones. The lab created one through the API (transcript t11) and its generated file, redirection_host/1.conf, is preserved in nginx-proxy-manager-lab/generated/: notice it is a smaller file than a proxy host's — a return instead of a proxy_pass — and that it passed the same standalone nginx test (transcript t13). One caution with teeth: a redirection host and a proxy host must not claim the same name. The newest record wins the file, and the loser confuses everyone; NPM will warn about duplicates, and the warning is right.

Dead hosts — the project's own term, under Hosts → 404 Hosts — are the deliberate dead end: a name that answers every request with a clean 404 Not Found. That sounds like a joke feature until you own a domain with stray subdomains pointing at your machine: instead of those names falling through to whatever default server might answer (and leaking which services exist), a dead host gives them a uniform, uninformative nothing. The form is just domain names and the same SSL tab as the others — a dead host with a certificate is still a dead end, only a politely encrypted one.

Streams leave the web behind entirely: they forward a raw TCP (or UDP) port from this machine to a port on another — a game server, a database you alone use, an SSH jump. The form is three numbers and a protocol: incoming port, forward IP, forward port. Streams live in nginx's separate stream configuration, not the HTTP one chapters 6 read, and their generated files land in /data/nginx/stream/. The lab did not run a stream: the sandbox has no UDP at all, and TCP forwarding is taught here from the documentation, as criteria.md records. Two limits to hold onto (chapter 13 repeats them): a stream knows nothing about names, so one incoming port serves exactly one destination; and anyone who can reach the port can use the forward, so a stream plus an access list mindset — firewall first — is the responsible way to open one.

The check: create a redirection host for a spare name and request it — curl -sI http://old.example.com/some/path should return your chosen status code and a Location: header pointing at the new address, path preserved if you asked for it. For a dead host, the check is the 404 itself, arriving without any hint of what else the machine runs.