Project

General

Profile

Feature #2474

Option to map send-file file-not-found error to normal 404

Added by Olaf-van-der-Spek about 4 years ago. Updated about 1 year ago.

Status:
Fixed
Priority:
Normal
Assignee:
-
Category:
mod_fastcgi
Target version:
Start date:
2013-02-13
Due date:
% Done:

100%

Missing in 1.5.x:
No

Description

I've got tons of errors like this (don't ask):
2013-02-13 19:49:02: (mod_fastcgi.c.2641) send-file error: couldn't get stat_cache entry for: /srv/xwis.net/screenshots/619420_t.jpg

Is there an option to map those to normal 404s without logging?

fastcgi-404-always.diff View - patch: always sends 404 if file is not present (2.48 KB) bert, 2013-09-16 14:02

fastcgi-404-option.diff View - patch: config option to send 404 if file is not present (4.48 KB) bert, 2013-09-16 14:03

Associated revisions

Revision 3088 (diff)
Added by stbuehler about 1 year ago

[mod_fastcgi] 404 for X-Sendfile file not found (fixes #2474)

(slightly modified from patch by bert)

From: Glenn Strauss <>

Revision c80ae9b2 (diff)
Added by gstrauss about 1 year ago

[mod_fastcgi] 404 for X-Sendfile file not found (fixes #2474)

(slightly modified from patch by bert)

From: Glenn Strauss <>

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3088 152afb58-edef-0310-8abb-c4023f1b3aa9

History

#1 Updated by darix about 4 years ago

call stat in your app before setting the x-sendfile header?

#2 Updated by Olaf-van-der-Spek about 4 years ago

I'd prefer not to. Besides, that app might not have access to the file or even run on another box.

#3 Updated by stbuehler over 3 years ago

  • Target version changed from 1.4.33 to 1.4.34

#4 Updated by bert over 3 years ago

Attached are two patches to do this.

One sends a 404 instead of 502 if the file turns out to be missing when using X-Sendfile or X-Sendfile2.

The second patch introduces an option ("allow-x-send-file-404", a boolean) to control this behavior. The default is to keep the current mod_fastcgi behavior and send a 502.

#5 Updated by darix over 3 years ago

  • Target version changed from 1.4.34 to 1.4.35

#6 Updated by stbuehler about 3 years ago

  • Target version changed from 1.4.35 to 1.4.36

#7 Updated by stbuehler almost 2 years ago

  • Target version changed from 1.4.36 to 1.4.37

#8 Updated by stbuehler over 1 year ago

  • Target version changed from 1.4.37 to 1.4.38

#9 Updated by stbuehler over 1 year ago

  • Target version changed from 1.4.38 to 1.4.39

#10 Updated by stbuehler over 1 year ago

  • Target version changed from 1.4.39 to 1.4.40

#11 Updated by gstrauss about 1 year ago

If a FastCGI application returned X-Sendfile (or related) and the file does not exist on the local server running lighttpd, then 404 Not Found does seem like a valid error response. 502 Bad Gateway imparts slightly less information, but if a backend FastCGI server is generating paths and is unable to validate existence of a file, there is little difference between 502 and 404.

@stbuehler: would you consider this if resubmitted as a pull request?

#12 Updated by stbuehler about 1 year ago

I'm fine with replacing 502 with 404 in this case, I don't see a good reason to add an option for it; adding an option just increases complexity.

I just never got around reviewing it, but I appreciate any help with this.

#13 Updated by gstrauss about 1 year ago

https://github.com/lighttpd/lighttpd1.4/pull/19

I slightly modified Olaf's patch to retain the error trace when stat_cache_get_entry() fails. If it should be removed for X-Sendfile, then it should also be removed for X-Sendfile2

#14 Updated by stbuehler about 1 year ago

  • Status changed from Patch Pending to Fixed
  • % Done changed from 0 to 100

Applied in changeset r3088.

Also available in: Atom