Configure ubuntu on digitalocean so that URL of main domain without www in front can work [closed]

I have a Ubuntu 20.04.3 LTS virtual machine running nginx/1.18.0 on DigitalOcean.

Currently, when I key in the URL https://www.main-domain.com, it works. However, when I key in the URL https://main-domain.com, I get the following error;

This site can’t be reached. main-domain.com’s server IP address could not be found.

I am not sure whether this is a DNS or nginx problem.

How can I configure the digitalocean Ubuntu VM such that the URL https://main-domain.com without the www in front works?