No input file specified by FastCGI

Hi,
We have our own framework written in PHP, but it’s using .html extension
(and change of this is not possible).
So when I put appropriate block in config, part of site is working, but
few rewrites is not.

here is my .html parsing block

location ~ .html$ {
if (!-f $request-filename) { return 404; break; }
root /path/to/files;
fastcgi_pass 127.0.0.1:8000;
fastcgi_index index.html;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
include fastcgi_params;
}

and rewrite rule that isn’t working there:

rewrite ^/user/(.)/moje.([0-9]+).html$ /moje.html?u=$1&showpage=$2
last;
rewrite ^/user/(.
)/(content|lista)/([0-9]+).html$
/moje.html?otheruser=$1&showpage=$3 last;
rewrite ^/user/(.)/(content|lista).html$ /moje.html?otheruser=$1
last;
rewrite ^/user/(.
)/(+).html$ /$2.html?u=$1 last;

previously, at Apache, it was working fine (but a little bit slow, so we
decide to move to nginx)

Please help me,
Mateusz Kozak.

Posted at Nginx Forum:

On Tue, Jun 16, 2009 at 09:39:55AM -0400, meal wrote:

fastcgi_index index.html;
rewrite ^/user/(.)/(content|lista).html$ /moje.html?otheruser=$1 last;
rewrite ^/user/(.
)/(+).html$ /$2.html?u=$1 last;

previously, at Apache, it was working fine (but a little bit slow, so we decide to move to nginx)

Try to move rewrites to specila location:

 location ^~ /user/ {
     rewrite ^/user/(.*)/moje.([0-9]+).html$
             /moje.html?u=$1&showpage=$2      last;
     ...
 }

Also, it’s better to use try_files instead of

 if (!-f $request-filename) { return 404; break; }

as here:

 location ~ \.html$ {
     try_files  $uri  /404.html;
     ...
 }

 location = /404.html {
     root /path/to/files;
 }

Spasiba Igor, but it still no works, even if I moved rewrites to
location like you proposed. Do you have any other ideas?
I think it’s issue specified with my .html parsing… Unfortunately, as I
wrote, we cannot change this to other extension.

Posted at Nginx Forum:

2009/6/16 Igor S. [email protected]:

error_page  /apth/to/log  debug;


Igor S.
Igor Sysoev

and perhaps pasting entire nginx.conf (or server block), too?

On Tue, Jun 16, 2009 at 10:59:19AM -0400, meal wrote:

Spasiba Igor, but it still no works, even if I moved rewrites to location like you proposed. Do you have any other ideas?
I think it’s issue specified with my .html parsing… Unfortunately, as I wrote, we cannot change this to other extension.

Could you create debug log of a failed request:

./configure --with-debug …

nginx.conf:

error_page /apth/to/log debug;

On Tue, Jun 16, 2009 at 10:17 PM, Edho P Arief[email protected]
wrote:

nginx.conf:
and perhaps pasting entire nginx.conf (or server block), too?


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

and “No input file specified” sounds like either

  • the rewrite is incorrect (pointing to wrong file), or
  • the fastcgi block is searching in wrong folder, or
  • the file exist but not readable by fastcgi process, or
  • something else?

I compiled nginx with debug support, here is log

Server: nginx/0.7.60
Date: Tue, 16 Jun 2009 15:46:31 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Content-Encoding: gzip

2009/06/16 17:46:31 29541#0: *1 write new buf t:1 f:0 000000000068FF10,
pos 000000000068FF10, size: 186 file: 0, size: 0
2009/06/16 17:46:31 29541#0: *1 http write filter: l:0 f:0 s:186
2009/06/16 17:46:31 29541#0: *1 http output filter
“/moje.html?otheruser=silia&showpage=2”
2009/06/16 17:46:31 29541#0: *1 copy filter:
“/moje.html?otheruser=silia&showpage=2”
2009/06/16 17:46:31 29541#0: *1 http postpone filter
“/moje.html?otheruser=silia&showpage=2” 0000000000699F28
2009/06/16 17:46:31 29541#0: *1 http gzip filter
2009/06/16 17:46:31 29541#0: *1 malloc: 0000000000690F00:12288
2009/06/16 17:46:31 29541#0: *1 gzip alloc: n:1 s:5928 a:8192
p:0000000000690F00
2009/06/16 17:46:31 29541#0: *1 gzip alloc: n:512 s:2 a:1024
p:0000000000692F00
2009/06/16 17:46:31 29541#0: *1 gzip alloc: n:512 s:2 a:1024
p:0000000000693300
2009/06/16 17:46:31 29541#0: *1 gzip alloc: n:512 s:2 a:1024
p:0000000000693700
2009/06/16 17:46:31 29541#0: *1 gzip alloc: n:256 s:4 a:1024
p:0000000000693B00
2009/06/16 17:46:31 29541#0: *1 gzip in: 0000000000699F58
2009/06/16 17:46:31 29541#0: *1 gzip in_buf:000000000068FFD0
ni:00000000006740C0 ai:116
2009/06/16 17:46:31 29541#0: *1 malloc: 00000000006CECF0:4096
2009/06/16 17:46:31 29541#0: *1 deflate in: ni:00000000006740C0
no:00000000006CECF0 ai:116 ao:4096 fl:0 redo:0
2009/06/16 17:46:31 29541#0: *1 deflate out: ni:0000000000674134
no:00000000006CECF0 ai:0 ao:4096 rc:0
2009/06/16 17:46:31 29541#0: *1 gzip in_buf:000000000068FFD0
pos:00000000006740C0
2009/06/16 17:46:31 29541#0: *1 gzip in: 00000000006900E0
2009/06/16 17:46:31 29541#0: *1 gzip in_buf:0000000000690020
ni:0000000000673B60 ai:53
2009/06/16 17:46:31 29541#0: *1 deflate in: ni:0000000000673B60
no:00000000006CECF0 ai:53 ao:4096 fl:4 redo:0
2009/06/16 17:46:31 29541#0: *1 deflate out: ni:0000000000673B95
no:00000000006CED61 ai:0 ao:3983 rc:1
2009/06/16 17:46:31 29541#0: *1 gzip in_buf:0000000000690020
pos:0000000000673B60
2009/06/16 17:46:31 29541#0: *1 free: 0000000000690F00
2009/06/16 17:46:31 29541#0: *1 http chunk: 10
2009/06/16 17:46:31 29541#0: *1 http chunk: 121
2009/06/16 17:46:31 29541#0: *1 write old buf t:1 f:0 000000000068FF10,
pos 000000000068FF10, size: 186 file: 0, size: 0
2009/06/16 17:46:31 29541#0: *1 write new buf t:1 f:0 0000000000000000,
pos 0000000000690230, size: 4 file: 0, size: 0
2009/06/16 17:46:31 29541#0: *1 write new buf t:0 f:0 0000000000000000,
pos 00000000006778E8, size: 10 file: 0, size: 0
2009/06/16 17:46:31 29541#0: *1 write new buf t:1 f:0 00000000006CECF0,
pos 00000000006CECF0, size: 121 file: 0, size: 0
2009/06/16 17:46:31 29541#0: *1 write new buf t:0 f:0 0000000000000000,
pos 0000000000463798, size: 7 file: 0, size: 0
2009/06/16 17:46:31 29541#0: *1 http write filter: l:1 f:1 s:328
2009/06/16 17:46:31 29541#0: *1 http write filter limit 0
2009/06/16 17:46:31 29541#0: *1 writev: 328
2009/06/16 17:46:31 29541#0: *1 http write filter 0000000000000000
2009/06/16 17:46:31 29541#0: *1 copy filter: 0
“/moje.html?otheruser=silia&showpage=2”
2009/06/16 17:46:31 29541#0: *1 http finalize request: 0,
“/moje.html?otheruser=silia&showpage=2” 1
2009/06/16 17:46:31 29541#0: *1 set http keepalive handler
2009/06/16 17:46:31 29541#0: *1 http close request
2009/06/16 17:46:31 29541#0: *1 http log handler
2009/06/16 17:46:31 29541#0: *1 free: 00000000006CECF0
2009/06/16 17:46:31 29541#0: *1 free: 0000000000000000
2009/06/16 17:46:31 29541#0: *1 free: 0000000000698F70, unused: 8
2009/06/16 17:46:31 29541#0: *1 free: 000000000068FEF0, unused: 2890
2009/06/16 17:46:31 29541#0: *1 event timer add: 20:
65000:1245167256695
2009/06/16 17:46:31 29541#0: *1 free: 00000000006A2180
2009/06/16 17:46:31 29541#0: *1 free: 00000000006A1D70
2009/06/16 17:46:31 29541#0: *1 hc free: 0000000000000000 0
2009/06/16 17:46:31 29541#0: *1 hc busy: 0000000000000000 0
2009/06/16 17:46:31 29541#0: *1 post event 00002AB734F94148
2009/06/16 17:46:31 29541#0: *1 delete posted event 00002AB734F94148
2009/06/16 17:46:31 29541#0: *1 http keepalive handler
2009/06/16 17:46:31 29541#0: *1 malloc: 00000000006A1D70:1024
2009/06/16 17:46:31 29541#0: *1 recv: fd:20 -1 of 1024
2009/06/16 17:46:31 29541#0: *1 recv() not ready (11: Resource
temporarily unavailable)
2009/06/16 17:46:32 29541#0: *1 post event 00002AB734F94148
2009/06/16 17:46:32 29541#0: *1 delete posted event 00002AB734F94148
2009/06/16 17:46:32 29541#0: *1 http keepalive handler
2009/06/16 17:46:32 29541#0: *1 recv: fd:20 638 of 1024
2009/06/16 17:46:32 29541#0: *1 malloc: 00000000006A2180:1248
2009/06/16 17:46:32 29541#0: *1 malloc: 0000000000698F70:4096
2009/06/16 17:46:32 29541#0: *1 http process request line
2009/06/16 17:46:32 29541#0: *1 http request line: “GET
/user/silia/content/2.html HTTP/1.1”
2009/06/16 17:46:32 29541#0: *1 http uri: “/user/silia/content/2.html”
2009/06/16 17:46:32 29541#0: *1 http args: “”
2009/06/16 17:46:32 29541#0: *1 http exten: “html”
2009/06/16 17:46:32 29541#0: *1 http process request header line
2009/06/16 17:46:32 29541#0: *1 http header: “Host: swir.us:83
2009/06/16 17:46:32 29541#0: 1 http header: “User-Agent: Mozilla/5.0
(X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042315
Firefox/3.0.10”
2009/06/16 17:46:32 29541#0: 1 http header: "Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,
/
;q=0.8"
2009/06/16 17:46:32 29541#0: *1 http header: “Accept-Language:
en-us,en;q=0.5”
2009/06/16 17:46:32 29541#0: *1 http header: “Accept-Encoding:
gzip,deflate”
2009/06/16 17:46:32 29541#0: 1 http header: "Accept-Charset:
ISO-8859-2,utf-8;q=0.7,
;q=0.7"
2009/06/16 17:46:32 29541#0: *1 http header: “Keep-Alive: 300”
2009/06/16 17:46:32 29541#0: *1 http header: “Connection: keep-alive”
2009/06/16 17:46:32 29541#0: *1 http header: “Cookie:
__utma=56877352.3795460516796146000.1237308151.1245077681.1245085203.16;
__utmz=56877352.1242057004.6.2.utmcsr=gry.swir.us|utmccn=(referral)|utmcmd=referral|utmcct=/;
__gads=ID=c42082e22896b935:T=1242056621:S=ALNI_MaoNXmB0LRDjKcwEKM9n7yQ4_EQbg”
2009/06/16 17:46:32 29541#0: *1 http header done
2009/06/16 17:46:32 29541#0: *1 event timer del: 20: 1245167256695
2009/06/16 17:46:32 29541#0: *1 generic phase: 0
2009/06/16 17:46:32 29541#0: *1 test location: “/”
2009/06/16 17:46:32 29541#0: *1 test location: “user/”
2009/06/16 17:46:32 29541#0: *1 using configuration “/user/”
2009/06/16 17:46:32 29541#0: *1 http cl:-1 max:1048576
2009/06/16 17:46:32 29541#0: *1 generic phase: 2
2009/06/16 17:46:32 29541#0: 1 http script regex:
"^/user/(.
)/moje.([0-9]+).html$"
2009/06/16 17:46:32 29541#0: 1 "^/user/(.)/moje.([0-9]+).html$" does
not match “/user/silia/content/2.html”, client: 83.5.37.96, server:
swir.us, request: “GET /user/silia/content/2.html HTTP/1.1”, host:
swir.us:83
2009/06/16 17:46:32 29541#0: 1 http script regex:
"^/user/(.
)/(content|lista)/([0-9]+).html$"
2009/06/16 17:46:32 29541#0: 1
"^/user/(.
)/(content|lista)/([0-9]+).html$" matches
“/user/silia/content/2.html”, client: 83.5.37.96, server: swir.us,
request: “GET /user/silia/content/2.html HTTP/1.1”, host: “swir.us:83
2009/06/16 17:46:32 29541#0: *1 http script copy: “/moje.html”
2009/06/16 17:46:32 29541#0: *1 http script args
2009/06/16 17:46:32 29541#0: *1 http script copy: “otheruser=”
2009/06/16 17:46:32 29541#0: *1 http script capture: “silia”
2009/06/16 17:46:32 29541#0: *1 http script copy: “&showpage=”
2009/06/16 17:46:32 29541#0: *1 http script capture: “2”
2009/06/16 17:46:32 29541#0: *1 http script regex end
2009/06/16 17:46:32 29541#0: *1 rewritten data: “/moje.html”, args:
“otheruser=silia&showpage=2”, client: 83.5.37.96, server: swir.us,
request: “GET /user/silia/content/2.html HTTP/1.1”, host: “swir.us:83
2009/06/16 17:46:32 29541#0: *1 post rewrite phase: 3
2009/06/16 17:46:32 29541#0: *1 uri changes: 11
2009/06/16 17:46:32 29541#0: *1 test location: “/”
2009/06/16 17:46:32 29541#0: *1 test location: “user/”
2009/06/16 17:46:32 29541#0: *1 test location: “50x.html”
2009/06/16 17:46:32 29541#0: *1 test location: ~ “.html$”
2009/06/16 17:46:32 29541#0: *1 using configuration “.html$”
2009/06/16 17:46:32 29541#0: *1 http cl:-1 max:1048576
2009/06/16 17:46:32 29541#0: *1 generic phase: 2
2009/06/16 17:46:32 29541#0: *1 http script complex value
2009/06/16 17:46:32 29541#0: *1 http script var: “GET
/user/silia/content/2.html HTTP/1.1”
2009/06/16 17:46:32 29541#0: *1 http script copy: “-filename”
2009/06/16 17:46:32 29541#0: *1 http script file op 0000000000000001
“GET /user/silia/content/2.html HTTP/1.1-filename”
2009/06/16 17:46:32 29541#0: *1 http script if
2009/06/16 17:46:32 29541#0: *1 http finalize request: 404,
“/moje.html?otheruser=silia&showpage=2” 1
2009/06/16 17:46:32 29541#0: *1 http special response: 404,
“/moje.html?otheruser=silia&showpage=2”
2009/06/16 17:46:32 29541#0: *1 http set discard body
2009/06/16 17:46:32 29541#0: *1 malloc: 000000000068FEF0:4096
2009/06/16 17:46:32 29541#0: *1 HTTP/1.1 404 Not Found

and server block from nginx.conf here:

listen 83;
server_name swir.us www.swir.us;

#access_log logs/host.access.log main;
error_log logs/debug.log debug;

gzip on;
gzip_comp_level 9;
gzip_types text/css application/x-javascript;

Posted at Nginx Forum:

Hello!

On Tue, Jun 16, 2009 at 09:39:55AM -0400, meal wrote:

Hi,
We have our own framework written in PHP, but it’s using .html extension (and change of this is not possible).
So when I put appropriate block in config, part of site is working, but few rewrites is not.

here is my .html parsing block

location ~ .html$ {
if (!-f $request-filename) { return 404; break; }

  •     if (!-f $request-filename) { return 404; break; }
    
  •     if (!-f $request_filename) { return 404; break; }
    

Maxim D.

Maxim, it works! Great thanks to you!

Posted at Nginx Forum: