Ubuntu - NginX - Redirect HTTP to HTTPS

/etc/nginx/sites-available/sharewiz.net
server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;
 
    # Discourage deep links by using a permanent redirect to home page of HTTPS site
    return 301 https://$host;
 
    # Alternatively, redirect all HTTP links to the matching HTTPS page
    # return 301 https://$host$request_uri;
}
 
server {
    listen 443 ssl;
    server_name www.example.com;
 
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
}