<% require "shellwords" %>
worker_processes 4;
daemon off;

events {
    worker_connections  1024;
}

upstream php {
    server unix:/tmp/php-fpm.sock max_fails=3 fail_timeout=3s;
    keepalive 16;
}

http {
    sendfile    on;
    tcp_nopush  on;

    keepalive_timeout  65;

    error_log logs/error.log.fifo notice;
    access_log logs/access.log.fifo;

    <% if ENV.has_key? "INDEX_DOCUMENT" and ENV['INDEX_DOCUMENT'] != nil %>
    index <%= ENV['INDEX_DOCUMENT'] %> index.html index.htm index.xhtml;
    <% else %>
    index index.html index.htm index.xhtml;
    <% end %>

    include mime.types;

    server {
        server_name localhost;
        listen <%= ENV['PORT'] %>;
        root <%= ENV['DOCUMENT_ROOT'] %>;

        include site.conf;

        <% Shellwords.split(ENV['NGINX_INCLUDES'].to_s).each do |f| %>
        include /app/<%= f %>;
        <% end %>
    }
}

<% require "shellwords" %>
worker_processes 4;
daemon off;

events {
    worker_connections  1024;
}
http {
    sendfile    on;
    tcp_nopush  on;

    keepalive_timeout  65;

    error_log logs/error.log.fifo notice;
    access_log logs/access.log.fifo;

    upstream php {
        server unix:/tmp/php-fpm.sock max_fails=3 fail_timeout=3s;
        keepalive 16;
    }

    <% if ENV.has_key? "INDEX_DOCUMENT" and ENV['INDEX_DOCUMENT'] != nil %>
    index <%= ENV['INDEX_DOCUMENT'] %> index.html index.htm index.xhtml;
    <% else %>
    index index.html index.htm index.xhtml;
    <% end %>

    include mime.types;

    server {
        server_name localhost;
        listen <%= ENV['PORT'] %>;
        root <%= ENV['DOCUMENT_ROOT'] %>;

        include site.conf;

        <% Shellwords.split(ENV['NGINX_INCLUDES'].to_s).each do |f| %>
        include /app/<%= f %>;
        <% end %>
    }
}

Move upstream to http context, where it's allowed
Move upstream to http context, where it's allowed
