No Input File Specified

Hi, I’m fairly new to Nginx (an Apache convert) and have run into an
issue where my site works, but one particular POST function fails with
“No Input File Specified.” The POST is a port of an old IPBv2 script to
submit scores into a database via the URL:
http://www.example.com/game/123/index.php?act=Arcade&do=newscore

I have verified permissions

In Apache, the RewriteRule was:
RewriteRule ^game/(.)/(.).php$ index.php?act=Arcade&do=newscore [L]

In nginx, I have:
rewrite ^/game/(.)/(.).php$ /index.php?act=Arcade&do=newscore last;

Here’s my site’s .conf (some info masked). Can anyone help point me in
a direction? I’m not sure what I’m missing and I’ve spent a solid 12
hours on it, so would greatly appreciate any help.

server {
listen 80;
server_name www.example.com;
root /var/www/example;
location / {
try_files $uri $uri/ @gss;
}
location ~ .php$ {
try_files $uri /index.php?$args =404;
if ($uri !~ “^/uploads/”) {
fastcgi_pass unix:/var/run/php-fcgi.pid;
}
location ~ /arcade/gamedata/(.)$ {
alias /var/www/example/arcade/gamedata/$1;
internal;
break;
}
location @gss {
#Rewrite the games
rewrite ^/game/(.
)/(.).php$ /index.php?act=Arcade&do=newscore
last;
rewrite ^/play/index.php$ /index.php?act=Arcade&do=newscore last;
rewrite ^/game/(.
)/arcade/(.)$ /arcade/$2 last;
rewrite ^/play/arcade/(.
)$ /arcade/$1 last;
rewrite ^/(.*).html$ /index.php?params=$1 last;
}
}

Posted at Nginx Forum:

2012/3/5 Sageth [email protected]:

   root            /var/www/example;
   location / {
           try_files $uri $uri/ @gss;
   }
   location ~ \.php$ {
     try_files $uri /index.php?$args =404;
     if ($uri !~ "^/uploads/") {
           fastcgi_pass   unix:/var/run/php-fcgi.pid;
     }

You need more than this here. Also rather than checking whether than
it starts with /uploads/ after entering uploads, you should create
separate location block to handle this url.

@Cliff - I tried what you said and got 404’s on any of the pages that
were being rewritten to .html pages, so it does seem that the rewrites
are being handled. Thanks for trying… I think that you might be onto
something with the processing order. I’ll have to take a look into it
in more depth. Frustratingly, I restored my backup vhosts .conf file,
and now it doesn’t seem to want to load any objects in the
/arcade/gamedata folder, which is preventing some of the games from
loading.

@Edho - What other information do you need? I didn’t want to put too
much for the sake of brevity, but I can post whatever you think might
help.

Posted at Nginx Forum:

Ahh! It works! I made the php location too complex and realized where
it was bombing after getting a 404 on submit. It was much, much more
simple than what I had. Between the 404 and reading in the page that
Cliff linked me to (or maybe one of the pages linked there), it said
that most people try to do too much with index.php and that /index.php
usually works. It most certainly did. I’m thrilled.

location ~ .php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/var/run/php-fcgi.pid;
}

Also, the “internal” reference worked before, but that had to be
removed… maybe it was working due to my browser’s cache? No idea.

Now, time to tweak and optimize. Thank you for your help!

Posted at Nginx Forum:

On Sun, 2012-03-04 at 20:11 -0500, Sageth wrote:

root /var/www/example;
internal;
}
}

I believe that what is happening is the .php$ location is matched
first, so your rewrite rules are never called for PHP scripts. See here
for the order Nginx processes locations:

http://nginx.org/en/docs/http/request_processing.html#simple_php_site_configuration

Specifically, the sentence “The first matching expression stops the
search and nginx will use this location.” The / location is used as a
fallback in case no specific regex location is matched.

Instead, something like this might work (untested):

location ~ .php$ {
rewrite ^/game/(.)/(.).php$ /index.php?act=Arcade&do=newscore
break;
rewrite ^/play/index.php$ /index.php?act=Arcade&do=newscore break;
rewrite ^/(.*).html$ /index.php?params=$1 break;
fastcgi_pass unix:/var/run/php-fcgi.pid;
}

location @gss {
rewrite ^/game/(.)/arcade/(.)$ /arcade/$2 last;
rewrite ^/play/arcade/(.*)$ /arcade/$1 last;
}

Regards,
Cliff