At this URL: https://wiki.servarr.com/sonarr/installation/reverse-proxy it has this text:
If you're using a non-standard http/https server port, make sure your Host header also includes it, i.e.: proxy_set_header Host $host:$server_port or proxy_set_header Host $http_host
I have found that making this change doesn't help me (I am using a non-standard HTTPS port in nginx). I have to set proxy_set_header X-Forwarded-Host $http_host or when I go to a page when not logged in I get redirected to the login page on the wrong port.