Make sure that your proxy is sending all the necessary headers set in the nginx configs here:
In particular, X-Forwarded-Proto is often not included by default.