ASP.NET Core unable to use Forwarded Headers

Ah - got it!!

I enabled debug logging and found the error:

{"EventId":1,"LogLevel":"Debug","Category":"Microsoft.AspNetCore.HttpOverrides.ForwardedHeadersMiddleware","Message":"Unknown proxy: [::ffff:145.40.109.133]:51474","State":{"Message":"Unknown proxy: [::ffff:145.40.109.133]:51474","RemoteIpAndPort":"[::ffff:145.40.109.133]:51474","{OriginalFormat}":"Unknown proxy: {RemoteIpAndPort}"}}

Which corresponds with this line in ASP.NET Core.

Turns out I needed to specify KnownNetworks in the ForwardedHeaders config. :man_facepalming:

The question now becomes what range of networks specifically for the proxies I should be allowing? I found the following request which is a few years old now: ( Request: Fly IP ranges - General - Fly.io. I guess I can just allow any network, but that doesn’t seem best practice (happy to be convinced otherwise though).