nginx redirect from www to non-www

Put it inside your server { } segment. For example, to redirect all user accessing www.idontlikewww.com to idontlikewww.com, the following config snippet will work.

if ($host = 'www.idontlikewww.com' ) {
    rewrite  ^/(.*)$  http://idontlikewww.com/$1  permanent;
}