I have read most of the questions about it but nothing seems to work for me. I must be doing something wrong so here is what I have done. I have made two server blocks in DigitalOcean hosting using Ubuntu and Nginx. I have uploaded all the website files to var/www/website-folder.
Now when I try to access the website then only one link works and redirects don't work. The website is yoalfaaz[dot]com
- Working: http://www.example.com
 - Not working: http://example.com
 - Not working: https://example.com
 - Now working: https://www.example.com (this link is what I want for my website)
 
I am using SSL from Namecheap and it worked perfectly when I used Hostgator hosting so one thing is sure that I am somewhere wrong in the setup. Below is the file in which I made changes /etc/nginx/sites-enabled.
server {
        listen 80 ;
        listen [::]:80 ;
         return 301 https://www.example.com$request_uri;
        # Add index.php to the list if you are using PHP
        index index.php index.html index.htm index.nginx-debian.html;
        server_name www.example.com example.com;
        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }
        location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }
        location ~ /\.ht {
        deny all;
        }
}
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    root /var/www/example.com/html;
    server_name www.example.com;
    # certs sent to the client in SERVER HELLO are concatenated in ssl_certificate
    ssl_certificate /home/name/example.com.chained.crt;
    ssl_certificate_key /home/name/example.com.key;
    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:50m;
    ssl_session_tickets off;
    # Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits
    #ssl_dhparam /path/to/dhparam.pem;
    # intermediate configuration. tweak to your needs.
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDH$
    ssl_prefer_server_ciphers on;
    # HSTS (ngx_http_headers_module is required) (15768000 seconds = 6 months)
    add_header Strict-Transport-Security max-age=15768000;
 # OCSP Stapling ---
    # fetch OCSP records from URL in ssl_certificate and cache them
    ssl_stapling on;
    ssl_stapling_verify on;
    resolver 8.8.8.8;
}
UPDATED: There was an issue with DNS lookup, I have fixed that and now 301 redirects are working fine (checked through curl -I). But still, the website isn't loading.
As nothing was working so, I tried to remove redirects and try to load website without SSL and surprisingly it loaded just fine. Now I am thinking that the issue might be due to SSL, as every other problem has been fixed (as pointed out by the community members).