真正的泛域名透明代理

#三级域名泛域名代理

server {
 
    listen 127.0.0.1:80;
    server_name *.host.example.com;

    #也可以用 server_name _;

    #不过这需要编译时加个参数,请google
 
    if ($host ~* ^([^\.]+)\.([^\.]+)\.([^\.]+)\.([^\.]+)$) {
        set $hostx $2.$3.$4;
        set $dir $1;
    }
 
    location  ~* ^.+\.(action|do|jsp|ftl) {
        proxy_set_header Host $hostx;
        rewrite (.*) /$dir$1 break;
        proxy_pass  http://127.0.0.1:8080;
        include proxy.conf; 
    }
 
    location /{
        index index.php index.html index.shtml;
        root /var/www/$dir;
    }
}

猜你喜欢

转载自nubix.iteye.com/blog/816590