LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-20-2013, 09:00 AM   #1
agriz
Member
 
Registered: Nov 2011
Posts: 197

Rep: Reputation: Disabled
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?
 
Old 10-20-2013, 12:52 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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
 
Old 10-20-2013, 12:58 PM   #3
agriz
Member
 
Registered: Nov 2011
Posts: 197

Original Poster
Rep: Reputation: Disabled
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.
 
Old 10-20-2013, 01:09 PM   #4
agriz
Member
 
Registered: Nov 2011
Posts: 197

Original Poster
Rep: Reputation: Disabled
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.

Last edited by agriz; 10-20-2013 at 01:46 PM.
 
Old 10-20-2013, 01:45 PM   #5
agriz
Member
 
Registered: Nov 2011
Posts: 197

Original Poster
Rep: Reputation: Disabled
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.
"

Last edited by agriz; 10-20-2013 at 02:04 PM.
 
Old 10-20-2013, 04:15 PM   #6
agriz
Member
 
Registered: Nov 2011
Posts: 197

Original Poster
Rep: Reputation: Disabled
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] RHL 6.0 Unable to download the Kickstart file/ Error downloading kickstart file AnApproach2DigestLinux Linux - Newbie 3 11-23-2012 05:50 PM
error- unable to access jar file fachhoch@gmail.com Linux - Newbie 2 05-31-2012 08:24 PM
lp: unable to print file: client-error-not-possible sharyasn LinuxQuestions.org Member Intro 0 10-19-2009 12:43 AM
error: Unable to create channel for file: Ook Slackware 2 10-14-2009 01:49 AM
[SOLVED] dpkg fatal error unable to open files list file Stale NFS file handle cmr26 Linux - Software 5 09-06-2009 04:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration