backend rewrite of subdomains

Eden Li eden at mojiti.com
Wed Dec 19 23:59:45 MSK 2007


server {
  # no server_name statement

  set $subdomain "index.html";
  if ($http_host ~ "^(.+?)\.") {
    set  $subdomain  $1;
  }

  rewrite  ^/(.*)   http://staging.example.com/$subdomain/$1 last;
}

probably works.  Note that "_" isn't a valid domain character.

On 12/19/07, Wayne E. Seguin <wayneeseguin at gmail.com> wrote:
> Igor,
>
> 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
>
> Thanks,
>
>   ~Wayne
>
>





More information about the nginx mailing list