O link que Michael Hampton postou explica as variáveis em mais detalhes, mas aqui está uma resposta direta.
server
{
listen 80;
server_name *.example.com;
return 301 https://$host$request_uri;
}
Você pode ver o trabalho usando curl e olhando para o cabeçalho.
[root@hm1 conf.d]# curl --head bob.example.com
HTTP/1.1 301 Moved Permanently
Server: nginx/1.9.13
Date: Wed, 06 Apr 2016 02:01:24 GMT
Content-Type: text/html
Content-Length: 185
Connection: keep-alive
Location: https://bob.example.com/
Strict-Transport-Security: max-age=15780000; preload
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
[root@hm1 conf.d]# curl --head alice.example.com
HTTP/1.1 301 Moved Permanently
Server: nginx/1.9.13
Date: Wed, 06 Apr 2016 02:01:39 GMT
Content-Type: text/html
Content-Length: 185
Connection: keep-alive
Location: https://alice.example.com/
Strict-Transport-Security: max-age=15780000; preload
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff