Redirect from a site with WWW to URL without WWW

if ( $host ~ ^www\.(?.+)$ ) {
return 301 $scheme://$domain$request_uri;
}