Welcome Guest, Not a member yet? Register   Sign In
Anyone use CI with Nginx?
#12

[eluser]Sire[/eluser]
[quote author="kylemac" date="1273189259"]Hey all, this may be an old post - but it comes up quite high in the google search so I thought I might mention that some of what you guys are doing can now be handled natively by nginx. Pay attention to the location block.

Code:
...
        # the try_files declaration looks for the actual file, and if !exist goes to your fallback.
        location / { try_files $uri $uri/ /index.php; }
...

Here is the nginx documentation of try_files - http://wiki.nginx.org/NginxHttpCoreModule#try_files[/quote]

This didn't work for me, but I wanted to use try_files and tested a few options. Here's what I have so far...

Code:
server {
    listen   80;
    server_name  domain;

    location / {
        root /var/www/domain;
        index index.php;
        
        if (-f $request_filename) {
            expires max;
            break;
        }

        try_files /maintenance.html $uri $uri/ @codeigniter;
    }

    location @codeigniter {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_param SCRIPT_FILENAME /var/www/domain/index.php;
        include fastcgi_params;
        fastcgi_param QUERY_STRING $request_uri;
    }

    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
        access_log        off;
        expires           30d;
    }
}

The file /maintenance.html doesn't usually exist, but if I want to bring the site down temporarily while I work on it, all I have to do is create maintenance.html in the web root and it will be displayed to users until it is removed.


Messages In This Thread
Anyone use CI with Nginx? - by El Forum - 09-05-2008, 06:59 PM
Anyone use CI with Nginx? - by El Forum - 09-05-2008, 08:01 PM
Anyone use CI with Nginx? - by El Forum - 09-05-2008, 08:04 PM
Anyone use CI with Nginx? - by El Forum - 09-05-2008, 08:25 PM
Anyone use CI with Nginx? - by El Forum - 09-05-2008, 10:40 PM
Anyone use CI with Nginx? - by El Forum - 10-04-2008, 10:54 PM
Anyone use CI with Nginx? - by El Forum - 04-19-2009, 07:18 PM
Anyone use CI with Nginx? - by El Forum - 07-13-2009, 01:44 PM
Anyone use CI with Nginx? - by El Forum - 08-10-2009, 03:53 PM
Anyone use CI with Nginx? - by El Forum - 05-06-2010, 12:40 PM
Anyone use CI with Nginx? - by El Forum - 05-06-2010, 05:35 PM
Anyone use CI with Nginx? - by El Forum - 05-24-2010, 10:11 PM
Anyone use CI with Nginx? - by El Forum - 11-24-2010, 04:34 PM
Anyone use CI with Nginx? - by El Forum - 02-28-2012, 08:20 PM
Anyone use CI with Nginx? - by El Forum - 02-28-2012, 10:13 PM



Theme © iAndrew 2016 - Forum software by © MyBB