X-Forwarded-For proxy tag not recognized by Discourse?

Why would you do the redirect there? Do it at the outer layer, where you’re terminating HTTPS.