jonseg / crud-admin-generator

An open source tool to generate a complete backend from a MySql database.
http://crud-admin-generator.com/
MIT License
1.43k stars 441 forks source link

Not coping well with nginx #57

Open sitilge opened 8 years ago

sitilge commented 8 years ago

Hi there,

Moved to nginx recently. Using this config but still when moving to example.com/someTable the 404 is thrown by nginx. Any ideas?

server {
    listen 80;
    listen [::]:80;

    server_name example.com;

    root /var/www/example.com/web;
    index index.php;

    allow all;
    disable_symlinks off;
    autoindex on;

    location / {
            try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
            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;
            fastcgi_param PHP_FLAG "engine=on";
            fastcgi_param PHP_FLAG "safe_mode=off";
            fastcgi_param PHP_VALUE "open_basedir=none";
            include fastcgi_params;
    }
}
zhujiaqi commented 8 years ago

Heres my nginx config, it works well. Hope this help.

Nginx/1.6.3

    server  {
            server_name 127.0.0.1;
            root    PATH_TO_WEBROOT;
            index   index.php;

            #site   root    is  redirected  to  the app boot    script
            location    =   /   {
                            try_files   @site   @site;
            }

            #all    other   locations   try other   files   first   and go  to  our front   controller  if  none    of  them    exists
            location    /   {
                            try_files   $uri    $uri/   @site;
            }

            #return 404 for all php files   as  we  do  have    a   front   controller
            location    ~   \.php$  {
                            return  404;
            }

            location    @site   {
                            fastcgi_pass            127.0.0.1:9000;
                            include fastcgi_params;
                            fastcgi_param       SCRIPT_FILENAME $document_root/index.php;
            }

            location    ~   .*/\.   {
                            deny    all;
            }

    }

and don't forget set the corresponding value in src/app.php $app['asset_path'] = '/resources';