效果是当访问a.haowan.com/xxxxx时,请求的真实路径是 b.haowan.com/a/xxxxx

server
    {
            listen  80;
            server_name  a.haowan.com;
            index index.php index.html index.htm;
            root   /data/www/a;

            location ~ ^/a/
            {
                proxy_redirect off;
                proxy_set_header Host b.haowan.com;
                proxy_pass http://192.168.10.10:80;
            }
            location /
            {

                set $domain default;
                if ( $http_host ~* "^(.*)\.haowan\.com")
                {
                    set $domain $1;
                }
                rewrite ^/(.*) /$domain/$1 last;
            }
    }


server
{

    listen 80;
    server_name b.haowan.com;
    index index.php index.html;
    root /data/www/b;
    location / {
        index index.html index.php;
    }
}
原文链接:http://bbs.linuxtone.org/thread-9384-1-1.html