LINUX.ORG.RU
решено ФорумAdmin

NginX: File not found.


0

1
# cat mor.conf
server {
        listen 80;
        server_name mor.lo www.mor.lo;
#       server_name_in_redirect off;

        access_log /home/www/mor/logs/access.log;
        error_log /home/www/mor/logs/error.log;

        root /home/www/mor/public_html;
        index index.php index.html index.htm default.html default.htm;
        # Support Clean (aka Search Engine Friendly) URLs
        location / {
                try_files $uri $uri/ /index.php?$args;
        }

        # deny running scripts inside writable directories
        location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
                return 403;
                error_page 403 /403_error.html;
        }

        location ~ \.php$ {
                fastcgi_pass php_upstream_mor;
                fastcgi_index index.php;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

        # caching of files
        location ~* \.(ico|pdf|flv)$ {
                expires 1y;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
                expires 14d;
        }
}
# cat upstream.conf
upstream php_upstream_mor {
	server unix:/home/www/mor/tmp/php-fpm.sock;
}
fastcgi_param   QUERY_STRING            $query_string;
fastcgi_param   REQUEST_METHOD          $request_method;
fastcgi_param   CONTENT_TYPE            $content_type;
fastcgi_param   CONTENT_LENGTH          $content_length;

fastcgi_param   SCRIPT_FILENAME         $request_filename;
fastcgi_param   SCRIPT_NAME             $fastcgi_script_name;
fastcgi_param   REQUEST_URI             $request_uri;
fastcgi_param   DOCUMENT_URI            $document_uri;
fastcgi_param   DOCUMENT_ROOT           $document_root;
fastcgi_param   SERVER_PROTOCOL         $server_protocol;

fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;
fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;

fastcgi_param   REMOTE_ADDR             $remote_addr;
fastcgi_param   REMOTE_PORT             $remote_port;
fastcgi_param   SERVER_ADDR             $server_addr;
fastcgi_param   SERVER_PORT             $server_port;
fastcgi_param   SERVER_NAME             $server_name;

fastcgi_param   HTTPS                   $https;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param   REDIRECT_STATUS         200;

В логах error.log появляется

«Primary script unknown» while reading response header from upstream

Какой он скрипт хочет найти, если ему всё указано опциями:

index index.php index.html index.htm default.html default.htm;
...
try_files $uri $uri/ /index.php?$args;
...
fastcgi_index index.php;
?

в начале все нормально

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

потом ты инклудишь переменные, в которых переопределяется на неправильное

fastcgi_param   SCRIPT_FILENAME         $request_filename;

Spoofing ★★★★★ ()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.