nginx-0.7.4

Cliff Wells cliff at develix.com
Mon Jun 30 23:45:50 MSD 2008


On Mon, 2008-06-30 at 18:51 +0100, Ed W wrote:

> However, I have quite a few rails sites and I would like to use a 
> variable in the proxy_pass definition also..
> 
> I would like to use $site to simplify this as follows (so that I can 
> chuck the whole lot in the include section):

You could try something like this (untested):

map $host $backend {
        hostnames;
        .admin.mysite.com mongrel_cluster_production.admin.mysite.com;
}

> 
>         upstream mongrel_cluster_production.admin.mysite.com {
>             server 127.0.0.1:8031;
>             server 127.0.0.1:8032;
>         }
> 
>         server {
>                 listen          1.2.3.4;
>                 server_name     admin.mysite.com *.admin.mysite.com ;
>                 set             $site  "admin.mysite.com";
> ...
>                 location / {
>                         include /etc/nginx/std_rails_root.conf;
>                         if (!-f $request_filename) {

                                  proxy_pass http://$backend;

>                                 break;
>                         }
>                 }
>         }
> 

Regards,
Cliff






More information about the nginx mailing list