Server blocks being ignored in Nginx

I am trying to redirect all the traffic to my canonical ans secured url using https://www…

I have read Nginx docs here and there, and it states that we should avoid ifs and use server blocks. I have checked that everything is correct using sudo nginx -T. However, I might be doing something wrong because I’m not getting the intended outcome that is:

http://domain.eu -> should https://www.domain.eu

http://www.domain.eu -> should https://www.domain.eu

https://domain.eu -> should https://www.domain.eu

server {
    listen 80 default_server;
    server_name www.redvi.eu redvi.eu;
    return 301 https://www.redvi.eu$request_uri;
}

server {
    listen 443 ssl; # managed by Certbot
    server_name redvi.eu;
    ssl_certificate /etc/letsencrypt/live/www.redvi.eu/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/www.redvi.eu/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    return 301 https://www.redvi.eu$request_uri;
}


server {
    listen 443 ssl; # managed by Certbot
    server_name www.redvi.eu;

    root /home/deploy/redvi/current/public;
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log info;

location ^~ /(assets|packs) {
  gzip_static on;
  expires max;
  add_header Cache-Control public;
}

try_files $uri/index.html $uri @puma;
location @puma {
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Host $http_host;
  proxy_set_header  X-Forwarded-Ssl on;
  proxy_redirect off;

  proxy_pass http://puma;
}

error_page 500 502 503 504 /500.html;
client_max_body_size 10M;
keepalive_timeout 10;

    ssl_certificate /etc/letsencrypt/live/www.redvi.eu/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/www.redvi.eu/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}