How can I enable www subdomain

Hi guys, I want to know how can I enable “www” (https://www.mydomain.com), but keep mydomain.com as primary hostname. I mean, redirecting from “www” to non-“www”, using let’s encrypt.

I found a guide about install nginx after to install discourse from docker, but I’m very noobie, so can anyone help me and explain me all steps. My forum is empty so no problem to reinstall everything if it’s necessary.

ps. Ubuntu 18, digital ocean vps droplet.