How to combine text and variables in fastcgi_param?

Hello there dear nginx people,

I am a beginner in nginx and also to mailing lists. :slight_smile: 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

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
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

Hello!

On Sun, Feb 23, 2014 at 01:59:39PM +0100, naxa wrote:

understand the ‘expression format’ used in fastcgi_param. I get
errors. Here are relevant parts from nginx.conf with line numbers:

Try this:

fastcgi_param SCRIPT_FILENAME “$document_root $fastcgi_script_name”;

or this:

fastcgi_param SCRIPT_FILENAME ‘$document_root $fastcgi_script_name’;

If a parameter includes special characters, the whole parameter
should be enclosed in single or double quotes.


Maxim D.
http://nginx.org/

On 2014.02.23. 14:51, Maxim D. wrote:

Just a quick note: thank you very much, it worked!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs