Non www, www redirect

None of the templates work with configuration:
Debian 10: Nginx + php-fpm, https, joomla domain.
It is necessary and remains to make a redirect from www to a domain without www via https

In my configuration, with the nginx.conf_redir file, the command works
rewrite ^ (. *) https: //% domain% $ 1 permanent;
return command works like this, without ssl:
return 301 https: //www.NEWDOMAIN.com$request_uri;

How to redirect from www to non-www domain via https? What command to add to nginx.conf_redir file?

  1. Please do not revive 2 month old threads
  2. Stop pushing your thread with editing them.
  3. You’ll get an answer, if someone can or want answer it.

ScIT, you don’t have to be so vindictive, you better do a redirect, I know you can)))

I made it myself, maybe someone will come in handy:
server {
listen 80;
# если надо
# server_name ru1.su www.ru1.su;

return 301 https://ru1.su$request_uri;

}

server {
listen 443 ssl;
# ssl config
server_name www.ru1.su;

return 301 https://ru1.su$request_uri;

}

server {
listen 443 ssl;
# ssl config
server_name ru1.su;

# ...

}

Now redirect pages through the nginx.ssl.conf_redir file, where

rewrite ^ / page1.html $ / page2.html permanent;

the team is working