• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Nginx config and trim removing necessary opening slash

Hello. New here though I've been coding my CI application for few months now. It's an open source comics reader.

I've been using the "tip" from bitbucket, because some issues in 2.0.2 were in my way. Still, I think this applies for other versions of CI2 as well.

Today I was trying to make a CLI interface for allowing safer database upgrades, and realized I needed to set the $config['uri_protocol'] to "AUTO".

Didn't work at all, because I was using Nginx 0.8.5 with "REQUEST_URI". So I decided to get into it to finally get nginx to work with "AUTO", so I could have the application to be more compatible with other servers in general, since it's a publicly distributed application.

So, with "REQUEST URI" this used to work (removing all unnecessary caching and security parts):

[In the nginx config]

location /manga/beta3 {
                # this sends all non-existing file or directory requests to index.php
                if (!-e $request_filename) {
                        rewrite ^/manga/beta3(.+)$ /manga/beta3/index.php?$1 last;

"if" is ugly on Nginx, and there's try_files.
Now with try_files, the most classic version of it, and "AUTO", the browser redirects indefinitely.

[In the nginx config]

location /manga/beta3 {
        root /manga/beta3;
        try_files $document_root$uri $document_root$uri/ $document_root/index.php;

Checking how the variable changes in URI.php, it starts with "/manga/beta3/admin/database/upgrade/" coming from $_SERVER['REQUEST_URI'], and at line 196:
[/system/core/URI.php line 196 in _detect_uri()]

        return str_replace(array('//', '../'), '/', trim($uri, '/'));
returns "admin/database/upgrade"
It removes the opening slash, which causes the infinite redirect. By just adding it on line 74,

[/system/core/URI.php line 74]

            if ($uri = $this->_detect_uri())

the try_files works just fine with Codeigniter.

So, "is this a bug?" or there's some Nginx setup that can work with it, without me messing with Codeigniter? For now I am going to make it work with a MY_ file, but I wondered if all the weird Nginx 0.7+ configurations I found in this forum were caused by this.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.