I'm writing an application in fuelphp. On my local vagrant box everything works perfectly. I've create a sub domain from my main server for the development box, forwarding to the IP of a digital ocean droplet, installed nginx, php5-fpm and all the other bits needed to get fuel working and the home page works properly but when I try to navigate to any other area of the site I get this error in the error.log

2013/12/06 22:54:46 [error] 10177#0: *2 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: xxx.xxx.xxx.xxx, server: xxx.xxxxxxx.com, request: "GET /region HTTP/1.1", host: "xxx.xxxxxxx.com"

the .conf for the virtual host is :

server {


    root /usr/share/nginx/html/fuel_app/public;
    server_name xxx.xxxxxxx.com;

    location / {
            index index.php index.html index.htm;
            try_files $uri $uri/ /index.html;
    }

    error_page 404 /404.html;

#        error_page 500 502 503 504 /50x.html;
#        location = /50x.html {
#              root /usr/share/nginx/html/fuel_app/public;
#        }

    location @handler {
            rewrite / /index.php;
    }

    location ~ .php/ {
            rewrite ^(.*.php)/ $1 last;
    }

    location ~ .php$ {
            if (!-e $request_filename) { rewrite / /index.php last; }
            expires        off;
            try_files $uri =404;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
    }
}

What am I missing here?

1

There are 1 best solutions below

0
On

i'm not an expert but this is the configuration that we use in production with nginx and php-fpm:

server {

listen            80;
server_name       www.yourserver.com
root              /var/www/YOURSITE/public;  # whatever is yours
index             index.php index.html index.htm;

location / {
    try_files   $uri $uri/ @handler;
    expires     30d;
}

location @handler {
    rewrite ^ /index.php?/$request_uri;
}

location ~ ^/index.php$ {
    fastcgi_pass        127.0.0.1:9000;
    fastcgi_index       index.php;
    fastcgi_param       SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param       PHP_VALUE open_basedir="/var/www/YOURSITE/:/usr/share:/tmp/";
    include             fastcgi_params;
}

location ~ \.php$ {
    deny all;
}

location ~* ^/(modules|application|system) {
    return 403;
}

error_page 404          /index.php;

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
    deny  all;
}

access_log /var/log/nginx/YOURSITE.it-access.log;
error_log /var/log/nginx/YOURSITE.it-error.log;

}

We have some different settings and mabye it's one of them. Another thing that I'll check is config.php. In many project we have to set base_url manually and maybe you also have to do it or you have settled it and you have to change it for your production configuration