How to redirect Nginx non-www to www domain over SSL

Originally published at: https://www.cyberciti.biz/faq/redirect-nginx-non-www-to-www-domain-over-ssl/

I am getting an error that reads, “Your connection is not secure” when trying to redirect https://theos.in/ to https://www.theos.in/ domain using HTTP 301. How do I redirect Nginx non-www to www domain over SSL?