Using https just in a specific page - nginx

I am using NGINX as a web server. I would like to use https just in my login page, all other pages should serve http connection. How is possible to redirect the user to https when he types "/login" url prefix and then redirect to "http" when he types any other url suffix?

Thanks


for example, like this

server {
    listen *:80;

    ...

    location /login {
        return 301 https://$server_name$request_uri;
    }

    ...
}

server {
    listen *:443;
    ...
    location /login {
        # usual settings, proxy_pass etc...
    }

    location / {
        return 301 http://$server_name$request_uri;
    }
}