Rewriting old domain to new with nginx

As simple as:

if ($host ~* "domain.old$") {
  rewrite ^\/?(.*)$ http://domain.new/$1 permanent;
  break;
}