Configuring nginx fastcgi for CGI :: Application

I am trying to get a C :: A application running in nginx fastcgi (debian 6.0) and use spawn-fcgi.

C :: The route is configured using $self->mode_param( path_info=> 1, param => 'rm' );

the problem is that any C: A app urls ( example.com/cities , example.com/profile/99 etc.) that I request, it always displays the home page, which example.com/index.pl does example.com/index.pl .

My nginx setup

 server { listen 80; server_name example.com; root /var/www/example.com/htdocs; index index.pl index.html; location / { try_files $uri $uri/ /index.pl; } location ~ .*\.pl$ { include fastcgi_params; # this is the stock fastcgi_params file supplied in debian 6.0 fastcgi_index index.pl; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PERL5LIB "/var/www/example.com/lib"; fastcgi_param CGIAPP_CONFIG_FILE "/var/www/example.com/conf/my.conf"; fastcgi_pass unix:/var/run/fcgiwrap.socket; } } 

I have successfully configured several php applications in a similar way.

in this case, however, I suspect that I do not pass the essential fastcgi_param until C :: A, which it requires.

What do you think?

+4
source share
2 answers

I decided to solve the problem with a workaround in my C :: A application. And I am documenting it here.

Therefore, I was not able to skip nginx by PATH_INFO before my C :: A application. To get around this, I set PATH_INFO with the value REQUEST_URI in my C :: A application so that it selects the correct mode of operation.

In addition, nginx does not skip QUERY_STRING , so I had to add $query_string to the catch all route to also skip QUERY_STRING down.

my nginx configuration ends as follows:

 server { listen 80; server_name example.com; root /var/www/example.com/htdocs; index index.pl index.html; location / { try_files $uri $uri/ /index.pl?$query_string; } location ~ .*\.pl$ { include fastcgi_params; # this is the stock fastcgi_params file supplied in debian 6.0 fastcgi_index index.pl; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PERL5LIB "/var/www/example.com/lib"; fastcgi_param CGIAPP_CONFIG_FILE "/var/www/example.com/conf/my.conf"; fastcgi_pass unix:/var/run/fcgiwrap.socket; } } 
+1
source

I support CGI :: Application and also use Nginx. I did not do the same, but I would try this:

 fastcgi_split_path_info ^(/index.pl)(.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_NAME $fastcgi_script_name; 

It is supposed to capture and forward the PATH_INFO that you need.

Literature:

+2
source

All Articles