server {
    listen 443 ssl;
    server_name www.{domain_name};

    {ssl_config}

    {proxy_config}

    # Redirect to non-www
    location / {
        rewrite ^(.*) https://{domain_name}:{https_port}$1 permanent;
    }    

    # letsencrypt
    location /.well-known/acme-challenge/ {
        root /var/www/certbot;
    }
}