fastcgi_pass inheritance

Igor Sysoev is at rambler-co.ru
Thu Jan 3 19:22:10 MSK 2008


On Wed, Jan 02, 2008 at 03:40:03PM +0100, Manlio Perillo wrote:

> Athan Dimoy ha scritto:
> >Manlio Perillo <manlio_perillo at ...> writes:
> >
> >>Athan Dimoy ha scritto:
> >>>Igor Sysoev <is at ...> writes:
> >>>>You may describe all fastcgi stuff (fastcgi_param/etc) except 
> >>>>fastcgi_pass
> >>>>even on http level, and it will be inherited to all servers and 
> >>>>locations
> >>>>until will be overriden in them.
> >>>How this can be done? I mean how to fill all fastcgi stuff on http 
> >>>level. Currently I fill all of them inside a location ~ \.php$ {...} 
> >>>block. Can I 
> >use 
> >>>such a location block on http level, common for all virtual servers?
> >>>
> >>Yes, you can.
> >>
> >
> >Hmm, are you sure that location can be used inside http? I've tried but 
> >Nginx replied with an error saying: "location" directive is not allowed 
> >here...
> >
> 
> location can not be used inside http block, but you can use the fastcgi 
> directives here.
> 
> 
> The only problem is with fastcgi_param.
> I'm not sure, but if you do something like:
> 
> http {
>    fastcgi_param x y;
>    fastcgi_param a b;
> 
>    server {
>        location / {
>            fastcgi_param c d;
> 
>            fastcgi_pass ...
>        }
>    }
> }
> 
> 
> then the FASTCGI parameters passed to the FASTCGI server at / will 
> receive only the c:d pair.

Usually all fastcgi_param's are common and the only SCRIPT_FILENAME is
required to set per server. So it could configured:

http {
    fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;;
    fastcgi_param QUERY_STRING     $query_string;
    ...

    server {

        location \.php$ {
            root   /path/to/script;
            fastcgi_pass   ...;


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





More information about the nginx mailing list