Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.
*2037 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream

 server {
    listen   80; ## listen for ipv4; this line is default and implied
    #listen   [::]:80 default ipv6only=on; ## listen for ipv6

    server_name .site.com;
    root /var/www/site;
    error_page 404 /404.php;
    access_log /var/log/nginx/site.access.log;
    index index.html index.php;


    if ($http_host != "www.site.com") {
             rewrite ^ http://www.site.com$request_uri permanent;
   }

    location ~* \.php$ {
        fastcgi_index   index.php;
        fastcgi_pass    127.0.0.1:9000;
        #fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
         fastcgi_buffer_size 128k;
         fastcgi_buffers 256 4k;
         fastcgi_busy_buffers_size 256k;
         fastcgi_temp_file_write_size 256k;
         fastcgi_read_timeout 240;

        include         /etc/nginx/fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
    }

    location ~ /\. {
        access_log off;
        log_not_found off;
        deny all;
    }

   location ~ /(libraries|setup/frames|setup/libs) {
       deny all;
       return 404;
   }

    location ~ ^/uploads/(\d+)/(\d+)/(\d+)/(\d+)/(.*)$ {
             alias /var/www/site/images/missing.gif; 
#i need to modify this to show only missing files. right now it is showing missing for all the files.

    }

    location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
            access_log off;
            expires 20d;
    }

    location /user_uploads/ {
            location ~ .*\.(php)?$
            {
                deny all;
            }
    }

    location ~ /\.ht {
             deny  all;
    }

}

php-fpm config is default and is not touched.

The problem is little strange for me. Error pages are showing File not found only if they are .php files. Other error files are clearly calling the 404.php file

site.com/test => calls 404.php
site.com/test.php => File not found.

I am searching and making changes. but it hasn't solved the problem.

share|improve this question
    
Please post the complete server block. –  Michael Hampton Oct 20 '13 at 20:35
    
I have updated the question.. –  Mahesh Oct 20 '13 at 20:48
    
Does the file /var/www/site/404.php actually exist? –  Michael Hampton Oct 20 '13 at 20:53
    
Yes and it displays 404.php's content to wrong links which are not ending with .php site.com/ind.asp is shown with 404.php –  Mahesh Oct 20 '13 at 20:56
    
i found the solution to my problem. `location ~ ^/uploads/(\d+)/(\d+)/(\d+)/(\d+)/(.*)$ {' i want to show the missing.gif if only the file is not available in that location. Can you please help me with that? –  Mahesh Oct 20 '13 at 21:13

1 Answer 1

up vote 1 down vote accepted
fastcgi_intercept_errors on

it solved the problem

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.