server { listen 80; server_name _; if ($http_x_forwarded_proto = 'http'){ return 301 https://$host$request_uri; } }