How to redirect the www.domain.com version of your website to domain.com version on Nginx?
Here is how. You basically have to make two server blocks. The block with your normal configuration should be the version you want, the version you want to redirect should have a simple rewrite rule alone.
For example, to redirect www.vidyut.net to vidyut.net, you set up your server blocks like this:
rewrite ^(.*) http://vidyut.net$1 permanent;