Directly after any proxy_pass
line add
proxy_set_header X-Forwarded-Proto $scheme;
Typically X-Forwarded-Proto
is used together with X-Forwarded-Host
like this:
proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Proto $scheme;