# Help understanding the correct fast cgi params

**URL:** <https://www.ruby-forum.com/t/help-understanding-the-correct-fast-cgi-params/195083>\
**Category:** NGINX\
**Created:** [September 16, 2010, 3:29pm UTC](https://www.ruby-forum.com/t/help-understanding-the-correct-fast-cgi-params/195083 "2010-09-16T15:29:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e36b37/32.png) [@thomas](https://www.ruby-forum.com/u/thomas)\
**Post date:** [September 16, 2010, 3:29pm UTC](https://www.ruby-forum.com/t/help-understanding-the-correct-fast-cgi-params/195083/1 "2010-09-16T15:29:13Z")

</div>

I got some help on this forum yesterday:  
[http://www.ruby-forum.com/topic/216989#new](http://www.ruby-forum.com/topic/216989#new)

That solved most of my problem; it does pretty much what it should.

The problem now is that all requests get routed to index.php without  
passing anything extra. (I use the codeigniter php framework if that  
matters.) The way the configuration file is right now everything gets  
passed to index.php without any extra info. So no matter what is in the  
url, the page that loads is as if you had just put index.php

If I were using apache, I would have a rewrite rule like so:  
RewriteRule ^(.\*)$ index.php?/$1 [L]

which makes a url be something nice like:

[example.com/controller/action](http://example.com/controller/action)

rather than

[example.com/index.php/controller/action](http://example.com/index.php/controller/action)

Now I also need to do that in nginx, but the script also needs to be  
sent to fast cgi (port 9000).

Here’s my nginx.conf so far (big thanks to Igor S. for helping me  
out a few hours ago. This is the same file from the link I posted at the  
beginning (the one Igor S. fixed)):

server {

listen 80; ## listen for ipv4  
listen [::]:80 default ipv6only=on; ## listen for ipv6

keepalive\_timeout 5 5;

gzip on;  
gzip\_proxied expired no-cache no-store private auth;  
gzip\_types text/plain application/xml  
application/x-javascript;

root /var/www/example.com/public/;

location / {  
fastcgi\_pass 127.0.0.1:9000;  
fastcgi\_index index.php;  
include fastcgi\_params;  
fastcgi\_param SCRIPT\_FILENAME  
/var/www/example.com/public/index.php$fastcgi\_script\_name;  
}

location ~\*  
^/sqlbuddy/.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$  
{  
access\_log off;  
expires 1s;  
}

location ~ ^/sqlbuddy/ {  
fastcgi\_pass 127.0.0.1:9000;  
fastcgi\_index index.php;  
include fastcgi\_params;  
fastcgi\_param SCRIPT\_FILENAME  
/var/www/example.com/public/$fastcgi\_script\_name;  
}

location ~\*  
.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$  
{  
access\_log off;  
expires 1s;  
}

}

---

<div class="post-metadata">

**Author:** ![thomas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e36b37/32.png) [@thomas](https://www.ruby-forum.com/u/thomas)\
**Post date:** [September 16, 2010, 8:51pm UTC](https://www.ruby-forum.com/t/help-understanding-the-correct-fast-cgi-params/195083/2 "2010-09-16T20:51:28Z")

</div>

On Thu, Sep 16, 2010 at 03:29:13PM +0200, Thomas Delonge wrote:

> listen 80; ## listen for ipv4
> 
> location / {  
> fastcgi\_pass 127.0.0.1:9000;  
> fastcgi\_index index.php;  
> include fastcgi\_params;  
> fastcgi\_param SCRIPT\_FILENAME  
> /var/www/example.com/public/index.php$fastcgi\_script\_name;

- 

```
fastcgi_param SCRIPT_FILENAME

```

- 

```
    /var/www/example.com/public/index.php$fastcgi_script_name;

```

- 

```
fastcgi_param SCRIPT_FILENAME

```

- 

```
    /var/www/example.com/public/index.php;

```

- 

```
fastcgi_param QUERY_STRING $fastcgi_script_name;

```

Also you should “include fastcgi\_params0;” where fastcgi\_param  
QUERY\_STRING  
has been removed.

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**
