Change Rewrite from http to https

After running gitlab over http for a while then changing to https I found that a the rewrite rule when cloning from the http url would prompt for a password (even for public repos) but  using return 301 https://$server_name$request_uri; the redirect to https work without password prompt.