You’ll need to make sure that the X-Forwarded-Proto header is set to https. You might also find this post helpful:
X-Forwarded-Proto
https