When using [Nginx + Varnish + Apache] or [Nginx + Apache] you need to tell Apache that an SSL request is being served by a proxy server. So use the code below to force SSL in .htaccess
SetEnvIf X-Forwarded-Proto "https" HTTPS=onRewriteEngine on RewriteCond %{HTTPS} !=on RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC] RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]