4
*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.

6
  • Please post the complete server block. Commented Oct 20, 2013 at 20:35
  • I have updated the question.. Commented Oct 20, 2013 at 20:48
  • Does the file /var/www/site/404.php actually exist? Commented Oct 20, 2013 at 20:53
  • 1
    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 Commented Oct 20, 2013 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? Commented Oct 20, 2013 at 21:13

2 Answers 2

3
fastcgi_intercept_errors on 

it solved the problem

1
location ~ \.php { .. try_files $uri =404; .. } 

Add this in php location block to tell nginx to check file exist before sending any request to FastCGI.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.