https to http redirect not working in nginx configuration using rewrite
<p>To distribute load and implement security in our application we have taken elastic Load Balancer from amazon and SSL is configured on it.Now the redirection from http to https is not working in nginx configuration on server or instances which is attached on ELB.
Here is following nginx configuration:-</p>

<pre><code> server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;
        server_name new.example.com;
        access_log /var/log/nginx/domain-access.log;
        location / {
                proxy_read_timeout 90;
                proxy_connect_timeout 90;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_pass http://127.0.0.1:8000;
              }
}
</code></pre>

<p>Firstly the server is not supporting https URLs then I add some proxy settings in configuration but now issue is that redirection is not working i have used the following commands in ngnix configuration to redirect http to https :-</p>

<pre><code>#version 1   
    server{
      return         301 https://$server_name$request_uri;
    }

#version 2   
    server {
     rewrite ^(.*) https://$host$1 permanent;
    }
</code></pre>

<p>Application deployed on server is build using django framework.</p>