Help understanding the correct fast cgi params

Igor Sysoev igor at sysoev.ru
Thu Sep 16 22:50:22 MSD 2010


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

> I got some help on this forum yesterday:
> 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
> 
> rather than
> 
> 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 Sysoev for helping me
> out a few hours ago. This is the same file from the link I posted at the
> beginning (the one Igor Sysoev 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;

-     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 Sysoev
http://sysoev.ru/en/



More information about the nginx mailing list