if ($server_port !~ 443){ rewrite ^(/.*)$ https://$host$1 permanent; }