You could try something like:
server {
listen 80;
listen 443 ssl;
server_name mydomain.com;
if ($scheme = 'http') { rewrite ^ https://$http_host$request_uri? permanent; }
location / { bla.....; }
}
ea. keep the 'if' outside the location blocks.
server {
listen 80;
listen 443 ssl;
server_name mydomain.com;
if ($scheme = 'http') { rewrite ^ https://$http_host$request_uri? permanent; }
location / { bla.....; }
}
ea. keep the 'if' outside the location blocks.