How to combine text and variables in fastcgi_param?

naxa anaxagramma at gmail.com
Sun Feb 23 12:59:39 UTC 2014


Hello there dear nginx people,

I am a beginner in nginx and also to mailing lists. :) Once read the
docs I can't say I am sure I remember all the important parts so please
excuse me if I am asking something silly. I'm having trouble with using
the `value` part `fastcgi_param` of ngx_http_fastcgi. I am using nginx
1.2.5.
I am trying to include four spaces between two variables. Here is an
example in markdown. This is cross-posted at
http://stackoverflow.com/questions/21968255

The [fastcgi_param
docs](http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_param)
reads

> A value can contain text, variables, and their combination.

Does not link or specify explicitly what the text format is or what the
combination format is.

I am trying to add four spaces between two variables in order to
understand the 'expression format' used in `fastcgi_param`. I get
errors. Here are relevant parts from `nginx.conf` with line numbers:

# try 1 with apostrophe `'`

    78: fastcgi_param  SCRIPT_FILENAME  $document_root'   
'$fastcgi_script_name;
    82: # deny access to .htaccess files, if Apache's document root

produces

    nginx: [emerg] unexpected "s" in <nginx.conf>:82

# try 2 (bare)
Another try

    78: fastcgi_param  SCRIPT_FILENAME  $document_root   
$fastcgi_script_name;

produces

    nginx: [emerg] invalid parameter "$fastcgi_script_name" in
<nginx.conf>:78

# try 3 with double quotse `"`

If I use `"` like this:

    78: fastcgi_param  SCRIPT_FILENAME  $document_root"   
"$fastcgi_script_name;

the error I get is:

    nginx: [emerg] unexpected end of file, expecting ";" or "}" in
<nginx.conf>:128

If I simply do

    78: fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

as usual, it works, *so I believe there is no other error in my*
`nginx.conf`.

Tried to look up the
[source](http://trac.nginx.org/nginx/browser/nginx/src/http/modules/ngx_http_fastcgi_module.c)
but due to its generalized nature, I couldn't yet find where the parse
and variable substitution is actually done.


How do I mix text and variables in a free-form way with nginx, in
particular in the value part of `fastcgi_param`?

I am using **nginx 1.2.5**.


Thank you,
Kristof




More information about the nginx mailing list