Apps behind nginx often announce themselves: X-Powered-By: PHP/8.1, X-AspNet-Version, or a framework name. Hiding the nginx version does little if the backend shouts its own.
location / {
proxy_pass http://127.0.0.1:8081;
proxy_hide_header X-Powered-By;
proxy_hide_header X-AspNet-Version;
}
Each line removes one header from the backend’s response before nginx passes it on. If the backend sends X-Powered-By and a Server-Timing header, only Server-Timing is left after the change. It works for any header name, so it is also how you drop debug headers an app adds in production.
nginx already hides a few by default, such as Date, Server and the X-Accel- headers. The opposite directive, proxy_pass_header, lets one of those through again.
Same trap as with add_header: the directive is inherited from the level above only when the current level has none of its own. Put one proxy_hide_header in a location and the ones from the server block stop applying there. So X-Powered-By shows up again in that location. I’d keep them all in a small snippet file and include it wherever you proxy. And hiding a version number is a small step. It slows down lazy scanners, but you still need to update the software behind it.
Further reading: proxy_hide_header
Going deeper: Guide: fix a 502 Bad Gateway in Nginx Proxy Manager, with a checklist that finds the cause