Вопрос

I have a .fcgi file that works with Apache, I just point the rewrite rules to the file and it does its job, but it seems Nginx is not able to work like this.

On Apache, I would just redirect the requests to the file. As from the original project .htaccess:

RewriteEngine On
RewriteBase /matrufsc
RewriteRule ^dispatch\.fcgi/ - [L]
RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]

So every request except from trying to access root is routed to dispatch.fcgi/$request. But Nginx is uncapable of executing files directly. What alternatives do I have to execute this file?

It is a python script that filters requests and takes action depending on requested "file". You can see the script source here at GitHub, and it works like this for Apache with the above htaccess. I have no knowledge of how to work with FastCGI.

How do I spawn a fastcgi process from Nginx? I have no clue on it or how to describe it better.

Это было полезно?

Решение

You are going to need to use a module called fastcgi.

The docs are here FastCGI Module.

An example location

location / {
    fastcgi_pass  localhost:9000;
    fastcgi_index index.php;

    fastcgi_param SCRIPT_FILENAME /home/www/scripts/php$fastcgi_script_name;
    fastcgi_param QUERY_STRING    $query_string;
    fastcgi_param REQUEST_METHOD  $request_method;
    fastcgi_param CONTENT_TYPE    $content_type;
    fastcgi_param CONTENT_LENGTH  $content_length;
}

This will also require a fastcgi daemon running as well. Installation of this daemon depends on your os.

Here is another page on the wiki that talks about fcgi.

http://wiki.nginx.org/FcgiExample

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top