Proxy subdomain root to a different server url

Igor Sysoev igor at sysoev.ru
Sat May 12 12:25:04 UTC 2012


On Sat, May 12, 2012 at 04:03:57PM +0400, Vahan Yerkanian wrote:
> Hi Chris,
> 
> I was missing $1 in the end of the uri so the rewrite works.
> Without it, it was being silently ignored and was creating a redirect loop.
> 
> For the mailing list archival purposes, here is what I ended up with:
> 
>         server {
>                 listen          11.22.33.44:80;
>                 server_name     abcd.domain.com;
> 
>                 location / {
>                         rewrite ^(.*)$ /path1/path2/filename$1 break;
>                         proxy_pass http://www.domain.com;
>                 }
>                 server_tokens   off;
>         }

This works without rewrites:

    location / {
         proxy_pass http://www.domain.com/path1/path2/filename/;
    }


-- 
Igor Sysoev



More information about the nginx mailing list