LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Nginx Error File - Unable to guess which file it calls (https://www.linuxquestions.org/questions/linux-software-2/nginx-error-file-unable-to-guess-which-file-it-calls-4175481498/)

agriz 10-20-2013 09:00 AM

Nginx Error File - Unable to guess which file it calls
 
A line in, sites-available/site.conf
Code:

error_page 404 404.html
I have also linked sites-available to sites-enabled.
Site is working without any problem

But if i type some wrong url, it is not showing

File is not available.

404.html has that line.

I changed the error_page to 404.php and i deleted 404.html from server

But i am still getting the same error message for wrong urls

I did a grep -r "File is not available" /
I didnt get any output.
Where does the error message comes from?

bathory 10-20-2013 12:52 PM

Hi,

The correct notation is
Code:

error_page  404  /404.php;
And I guess you've restarted nginx after editing the configuration and cleared your browser cache

Regards

agriz 10-20-2013 12:58 PM

Thanks a lot. A slash changed everything.
I was wasting a lot of time :)

I tried to check site.com/wrongurl.some_ext. It is working correctly.
I tried to check again site.com/some_folder/wrong_url It works, but the styles are gone.

agriz 10-20-2013 01:09 PM

Code:

<link type="text/css" media="all" href="../style.css" rel="stylesheet">
if i add ../ in front of css js and images it works properly.
Is there a way to fix it on the nginx config?

I need to set one more error page for images.
uploads/2013(year)/month/date/image.gif|jpg|png -> if the image is not found i need to show unavailable image.

But i already have

Code:

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

EDIT
I have done this image error page properly.

agriz 10-20-2013 01:45 PM

I have a problem with error rewrite.

It shows the error page when the url is not related with .php

site.com/err.php is still showing "File not found" text.
site.com/any.extention shows error page!

Where does it call this "file not found" text?

If it is a php call, then it throws the following error in nginx/error.log

Code:


*2037 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream

Code:


server_name .site.com;

root /var/www/site.com;
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$ {
#          try_files $uri = 404;
            fastcgi_index  index.php;
            fastcgi_pass    127.0.0.1:xxxx;           
            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;
        }

chrome and firefox are showing "File not found."
Internet explorer is showing "Most likely causes:
•There might be a typing error in the address.
•If you clicked on a link, it may be out of date.
"

agriz 10-20-2013 04:15 PM

fastcgi_intercept_errors on

it solved the problem.
Thanks for your help.

Code:

location ~ ^/uploads/(\d+)/(\d+)/(\d+)/(\d+)/(.*)$ {
      alias /var/www/site/images/missing.gif;
}

The above code displays missing.gif for everything.
I want to show that missing.gif if only the file is not available.


All times are GMT -5. The time now is 11:43 PM.