Add the following block before the existing server
block, in the nginx configuration, where domain-name.com
is the domain of the website:
server {
server_name www.domain-name.com;
return 301 $scheme://domain-name.com$request_uri;
}