404 instead of "no inout file specified"?
Leechael Yim
yanleech at gmail.com
Tue Jul 7 21:47:34 MSD 2009
<code lang="nginx">
if (-f $request_filename) { fastcgi_pass 127.0.0.1:9000;
}
</code>
OR:
<code lang="nginx">
if (!-f $request_filename) {
return 404;
}
fastcgi_pass 127.0.0.1:9000;
</code>
The first one is what I current used with my Nginx.
On Wed, Jul 1, 2009 at 10:20 PM, Maxim Dounin <mdounin at mdounin.ru> wrote:
> Hello!
>
> On Wed, Jul 01, 2009 at 02:52:06PM +0100, Nuno Magalhães wrote:
>
> > Greetings,
> >
> > If i provide a valid URL, it's processed.
> > If i provide an invalid URL, nginx shows the 404 page except it the
> > invalid URL ends in .php - in that case i get the "no input file
> > specified" message.
>
> Looks like you've configured passing urls ending with ".php" to
> php for processing. So you got errors from php, not from nginx.
> It's expected behaviour, no?
>
> And, actually, "no input file specified" *is* 404 error. It's
> just has some fancy php-specific content.
>
> > I'm in the process of changing my php files to an html extension (i
> > assume that would "fix" things), however, i'd like to get a 404
> > instead of the message regardless.
> >
> > I tried using "fastcgi_intercept_errors off" in the conf for my server
> > (in sites-available), but it didn't do anything (i did restart both
> > nginx and the fast-cgi processes).
> >
> > Is there a better way?
>
> If you want to change error page returned by php to something
> pretty-looking, you should:
>
> 1. Use "fastcgi_intercept_errors on;" to instruct nginx to
> intercept and change errors returned by fastcgi application.
>
> 2. Make sure you explicitly configured error_page for 404.
> Default compiled-in error pages are used only for nginx own
> errors, not for fastcgi_intercept_errors/proxy_intercept_errors.
>
> So your resulting config should look like:
>
> error_page 404 /404.html;
>
> location ~ \.php$ {
> fastcgi_pass ...;
> fastcgi_intercept_errors on;
> }
>
> ...
>
> Maxim Dounin
>
>
--
Twitter: http://www.twitter.com/leechael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20090708/62b52445/attachment.html>
More information about the nginx
mailing list