The plain HTTP request was sent to HTTPS port

I have tried to setup ssl with the erpnext site.
edited the nginx.conf file as follow for frappe-bench

server {
        listen 80;
        listen 443 default ssl ;
        server_name
                site1.local
                ;

        #FORCE HTTPS
        if ($scheme = http) {
        return 301 https://$server_name$request_uri;
        }
        ssl on;
        ssl_certificate      /etc/nginx/ssl/server.crt;
        ssl_certificate_key  /etc/nginx/ssl/server.key;
        #FORCE HTTPS ENDS HERE --

        root /home/erpnext/frappe-bench/sites;

        [....]
}

but the site works perfectly when called as > https://server.com
when I tried to access it from http as normal 80 site then it is not getting redirected to the https site.

it throws an error :

400 Bad Request

The plain HTTP request was sent to HTTPS port

Why is it not redirecting to https.

regards

Look up nginx help!