worker_processes 4;
daemon off;

events {
    worker_connections  1024;
}

http {
    upstream phpfpm {
        server unix:/tmp/php-fpm.sock;
    }

    sendfile    on;
    tcp_nopush  on;

    keepalive_timeout  65;
     
    error_log logs/error.log notice;
    access_log logs/access.log;

    server {
        listen <%= ENV['PORT'] %>;
     
        server_name localhost;
        root <%= ENV['DOCUMENT_ROOT'] %>;
     
        rewrite ^/<%= ENV['INDEX_DOCUMENT'].gsub(".", "\\.") %>/?(.*)$ /$1 permanent;
     
        location / {
            index index.php;
            try_files $uri @rewriteapp;
        }
     
        location @rewriteapp {
            rewrite ^(.*)$ /<%= ENV['INDEX_DOCUMENT'] %>/$1 last;
        }
     
        # pass the PHP scripts to FastCGI server from upstream phpfcgi
        location ~ \.php$ {
            fastcgi_pass phpfcgi;
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            include fastcgi_params;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param  HTTPS off;
        }
    }
}

worker_processes 4;
daemon off;

events {
    worker_connections  1024;
}

http {
    upstream phpfpm {
        server unix:/tmp/php-fpm.sock;
    }

    sendfile    on;
    tcp_nopush  on;

    keepalive_timeout  65;
     
    error_log logs/error.log notice;
    access_log logs/access.log;

    server {
        listen <%= ENV['PORT'] %>;
     
        server_name localhost;
        root <%= ENV['DOCUMENT_ROOT'] %>;
     
        rewrite ^/<%= ENV['INDEX_DOCUMENT'].gsub(".", "\\.") %>/?(.*)$ /$1 permanent;
     
        location / {
            index index.php;
            try_files $uri @rewriteapp;
        }
     
        location @rewriteapp {
            rewrite ^(.*)$ /<%= ENV['INDEX_DOCUMENT'] %>/$1 last;
        }
     
        # pass the PHP scripts to FastCGI server from upstream phpfcgi
        location ~ \.php$ {
            fastcgi_pass phpfpm;
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            include fastcgi_params;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param  HTTPS off;
        }
    }
}

Fix upstream name in fastcgi_pass
Fix upstream name in fastcgi_pass
