# No Input File Specified

**URL:** <https://www.ruby-forum.com/t/no-input-file-specified/217556>\
**Category:** NGINX\
**Created:** [March 5, 2012, 2:11am UTC](https://www.ruby-forum.com/t/no-input-file-specified/217556 "2012-03-05T02:11:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [March 5, 2012, 2:11am UTC](https://www.ruby-forum.com/t/no-input-file-specified/217556/1 "2012-03-05T02:11:54Z")

</div>

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](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](http://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:

> **[No Input File Specified](https://forum.nginx.org/read.php?2,223362,223362#msg-223362)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![Sageth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@Sageth](https://www.ruby-forum.com/u/Sageth)\
**Post date:** [March 5, 2012, 3:19am UTC](https://www.ruby-forum.com/t/no-input-file-specified/217556/2 "2012-03-05T03:19:15Z")

</div>

2012/3/5 Sageth [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> ```
> 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.

---

<div class="post-metadata">

**Author:** ![Sageth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@Sageth](https://www.ruby-forum.com/u/Sageth)\
**Post date:** [March 5, 2012, 4:29am UTC](https://www.ruby-forum.com/t/no-input-file-specified/217556/3 "2012-03-05T04:29:40Z")

</div>

@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:

> **[Re: No Input File Specified](https://forum.nginx.org/read.php?2,223362,223369#msg-223369)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![Sageth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@Sageth](https://www.ruby-forum.com/u/Sageth)\
**Post date:** [March 5, 2012, 5:06am UTC](https://www.ruby-forum.com/t/no-input-file-specified/217556/4 "2012-03-05T05:06:54Z")

</div>

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:

> **[Re: No Input File Specified](https://forum.nginx.org/read.php?2,223362,223371#msg-223371)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![Sageth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@Sageth](https://www.ruby-forum.com/u/Sageth)\
**Post date:** [March 5, 2012, 3:35am UTC](https://www.ruby-forum.com/t/no-input-file-specified/217556/5 "2012-03-05T03:35:19Z")

</div>

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:

> **[How nginx processes a request](http://nginx.org/en/docs/http/request_processing.html#simple_php_site_configuration)**
>
> nginx first decides which server should process the request. Let’s start with a simple configuration where all three virtual servers listen on port \*:80:

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
