backend rewrite of subdomains

Igor Sysoev is at rambler-co.ru
Thu Dec 20 10:05:32 MSK 2007


On Wed, Dec 19, 2007 at 03:41:00PM -0500, Wayne E. Seguin wrote:

> I've searched the mailing lists and read the docs and played around with the
> server but can't quite come up with what I'm trying to do.
> 
> I am trying to configure
> 
> *.staging.example.com proxy to backend staging.example.com/*
> 
> so for example:
> 
> hi_mom.staging.example.com in the backend goes to
> staging.example.com/hi_mom/...
> 
> but the clients do not see the rewrite, eg they stay on
> hi_mom.staging.example.com
> 
> Is there a way to do this with Nginx?
> 
> The only thing I've found that is close is :
> http://pastie.textmate.org/private/7oox7dwjlejheocxufg

server {
    server_name   .staging.example.com;

    if ($http_host ~ ^(.+)\staging\.example\.com) {
        set        $name    $1;
        rewrite    ^(.+)$   /$name$1;
    }

    location / {
        proxy_pass  http://staging.example.com:8000;
    }
}


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list