server {
    listen 80;
    server_name www.xxx.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443;
    server_name www.xxx.com;
    ssl_certificate /etc/nginx/ssl/www.xxx.com.pem;
    ssl_certificate_key /etc/nginx/ssl/www.xxx.com.key;
    ssl on;
    root /home/www/xxx;
    location / {
        # ...
    }
}