> with ASP.NET Core this could and should be solved with Middleware
That comes with some caveats - if you are already using IIS or some reverse proxy/edge server then configuring this at the edge will be more performant and the request won't hit your app at all (which is inherently more secure).
Will be good to see a package for this though, as plenty of people look to be using Kestrel at the edge now, and for some this will be the most useful place to implement.