I think the best and only way should be using a HTTP 301 Moved Permanently redirect like this:
return 301 https://$host$request_uri;
The HTTP 301 301 Moved Permanently redirect is also the most efficient because there is no regex to be evaluated, according to already mentioned pitfails).
If you don't want to change the hostname (and subdomain) this is the way.
This does still work if you have no DNS, as I am using it locally.
I am requesting for example with
http://192.168.0.100/index.php and will get redirected to exactly
https://192.168.0.100/index.php. Thats what I want.
listen [::]:80 on my host because i have bindv6only set to false, so it also binds to ipv4 socket. change it to
listen 80 if you don't want IPv6 or want to bind elsewhere.
The solution from Saif Bechan uses the server_name which in my case is localhost but that is not reachable over a network.
The solution from Michael Neale is good, but according to the pitfails, there is a better solution with redirect 301 ;)