fastcgi_param in server context does not work

Michael Shadle mike503 at gmail.com
Wed Sep 23 20:51:12 MSD 2009


Oh, wow.

To me, that seems like a bug, or at least an unwanted behavior. That
doesn't really follow any kind of pattern I've ever seen.

I can't see the need to pass the same pair twice for any reason - if
so I'd think it would be something like

fastcgi_param  SOMETHING[]  1;
fastcgi_param  SOMETHING[]  2;

or something along those lines if someone -really- wanted two values.

2009/9/23 Maxim Dounin <mdounin at mdounin.ru>:
> Hello!
>
> On Wed, Sep 23, 2009 at 03:14:10AM -0700, Michael Shadle wrote:
>
>> i used to set fastcgi_params on the global level, but now i have a
>> fastcgi.conf file with all the params that i include in my location
>> block for php - this allows me to alter the array like one would
>> expect. :)
>
> Note that you can't *redefine* params already defined on the same
> level.  I.e. writing (either direct or via include)
>
>    fastcgi_param  SOMETHING  1;
>    fastcgi_param  SOMETHING  2;
>
> will send *two* name-value pairs to fastcgi application.  It's up to
> application to use either both or one of them.
>
> In practice, PHP is known to behave differently in different
> versions.  After 5.2 it uses last value supplied, before - first
> one.
>
> Maxim Dounin
>
>
>>
>> On Wed, Sep 23, 2009 at 2:46 AM, Tomasz Pajor <nikon at puffy.pl> wrote:
>> > Tomasz Pajor wrote:
>> >>
>> >> So there is no way to create such a configuration:
>> >>
>> >> # fastcgi.conf
>> >> root /vhosts/landingpage/public;
>> >> charset utf-8;
>> >>
>> >> fastcgi_index index.php;
>> >>
>> >> location / {
>> >>   try_files $uri $uri/ @fallback;
>> >>   fastcgi_pass unix:/var/run/spawn-fcgi.sock;
>> >>   fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
>> >>   include fastcgi_params;
>> >> }
>> >>
>> >> location @fallback {
>> >>   fastcgi_pass unix:/var/run/spawn-fcgi.sock;
>> >>   fastcgi_param SCRIPT_FILENAME $document_root/index.php;
>> >>   include fastcgi_params;
>> >> }
>> >>
>> >> # landingpage.conf
>> >> server {
>> >>   listen 80;
>> >>   server_name .site1.landingpage.dev;
>> >>   access_log off;
>> >>   error_log /var/log/nginx/site1.landingpage.log;
>> >>
>> >>   fastcgi_param SITE site1;
>> >>   include fastcgi.conf;
>> >> }
>> >>
>> >> server {
>> >>   listen 80;
>> >>   server_name .site2.landingpage.dev;
>> >>   access_log off;
>> >>   error_log /var/log/nginx/site2.landingpage.log;
>> >>
>> >>   fastcgi_param SITE site2;
>> >>   include fastcgi.conf;
>> >> }
>> >
>> > I've been going through emails, and I came up with a good solution to my
>> > configuration, based on Igor and Maxim suggestion in Conditional
>> > fastcgi_param thread.
>> > Thanks!
>> >
>> > # landingpage-fastcgi.conf
>> > access_log off;
>> > root /vhosts/landingpage/public;
>> > charset utf-8;
>> > fastcgi_index index.php;
>> >
>> > location / {
>> >   try_files $uri $uri/ @fallback;
>> >   fastcgi_pass unix:/var/run/spawn-fcgi.sock;
>> >   fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
>> >   fastcgi_param SITE $landingpage_site;
>> >   include fastcgi_params;
>> > }
>> >
>> > location @fallback {
>> >   fastcgi_pass unix:/var/run/spawn-fcgi.sock;
>> >   fastcgi_param SCRIPT_FILENAME $document_root/index.php;
>> >   fastcgi_param SITE $landingpage_site;
>> >   include fastcgi_params;
>> > }
>> >
>> > # landingpage.conf
>> > map $http_host $landingpage_site {
>> >   default site1;
>> >   .site1.landingpage.dev site1;
>> >   .site2.landingpage.dev site2;
>> > }
>> >
>> > server {
>> >   listen 80;
>> >   server_name .landingpage.dev .site1.landingpage.dev;
>> >   error_log /var/log/nginx/landingpage/site1-error.log;
>> >   include landingpage-fastcgi;
>> > }
>> >
>> > server {
>> >   listen 80;
>> >   server_name .site2.landingpage.dev;
>> >   error_log /var/log/nginx/landingpage/site2-error.log;
>> >   include landingpage-fastcgi;
>> > }
>> >
>> >
>> >
>> >
>> >
>> >
>>
>
>





More information about the nginx mailing list