域名跳转的配置如下:

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

可以用curl测试。如下:

[[email protected] vhosts]# curl -x127.0.0.1:80  www.123.com -I
HTTP/1.1 301 Moved Permanently
Server: nginx/1.4.4
Date: Wed, 04 Jan 2017 05:46:14 GMT
Content-Type: text/html
Content-Length: 184
Connection: keep-alive
Location: http://www.test.com/