Try these rules:
(in www.domain.com's server block)
rewrite ^/$ http://domain.com permanent break;
rewrite ^/main(.*)$ http://domain.com$1 permanent break;
rewrite ^(.*)$ http://blog.domain.com$1 permanent;
Make sure you reload nginx.
With this config:
- http://www.domain.com/ redirects to http://domain.com
- http://www.domain.com/main/something redirects to http://domain.com/something
- Everything else redirects to http://blog.domain.com/