Using Variable in fastcgi_pass

Samuel Vogel samydelux at gmail.com
Mon Oct 20 20:08:06 MSD 2008


Maybe it would be helpful if I included my config file:
server {
        listen 127.0.0.1:81;
        server_name  localhost;

        set $userid "default";

        if ($host ~ "^(.+)\.user\.domain\.net$") {
                set $userid $1;
        }

        root   /www/$userid;
        index  index.html index.htm;

        location ~ \.php$ {
                fastcgi_pass   unix:/var/run/php-fpm/socket/$userid;
        }
}

Samuel Vogel schrieb:
> Hey,
>
> I am trying to use a variable in the fastcgi_pass directive. It does 
> not get parsed however.
>
> Example:
> 2008/10/20 12:09:59 [crit] 4475#0: *3 connect() to 
> unix:/var/run/php-fpm/socket/$userid failed (2: No such file or 
> directory) while connecting to upstream, client: 127.0.0.1, server: 
> localhost, request: "GET /info.php HTTP/1.1", upstream: 
> "fastcgi://unix:/var/run/php-fpm/socket/$userid:", host: 
> "345232.user.domain.net"
>
> Is this not supported? It would be a really important feature to me, 
> since it would enable me to not have to reload nginx periodically with 
> a new config file!
>
> Regards,
> Samy





More information about the nginx mailing list