Custom error pages that quietly return 200
With error_page 404 /404.html;, missing pages return 200 and search engines index junk URLs.
The internal redirect serves /404.html, and if that file exists and responds normally, the status becomes 200. Keep the original:
error_page 404 = /404.html;
The equals sign is the point: it keeps the original status while serving the replacement. =404 forces a specific code.
The same bug affects 502 pages — error_page 502 /502.html; returns 200 and monitoring stops seeing failures.
curl -sI https://example.com/not-exist | head -1