# This file is based on /usr/local/nginx/conf/nginx.conf.default.

# One worker process per core
error_log stderr error;

events {
    # This needed to be increased because the nginx error log said so.
    # http://nginx.org/en/docs/ngx_core_module.html#worker_connections
    worker_connections  65535;
    multi_accept on;
}

http {
    default_type  application/octet-stream;
    client_body_temp_path      /tmp;

    # turn off request logging for performance
    access_log off;

    # I think these only options affect static file serving
    sendfile        on;
    tcp_nopush      on;

    # Allow many HTTP Keep-Alive requests in a single TCP connection before
    # closing it (the default is 100). This will minimize the total number
    # of TCP connections opened/closed. The problem is that this may cause
    # some worker processes to be handling too connections relative to the
    # other workers based on an initial imbalance, so this is disabled for
    # now.
#    keepalive_requests 1000;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    server {
        # For information on deferred, see:
        # http://nginx.org/en/docs/http/ngx_http_core_module.html#listen
        # http://www.techrepublic.com/article/take-advantage-of-tcp-ip-options-to-optimize-data-transmission/
        # The backlog argument to listen() is set to match net.ipv4.tcp_max_syn_backlog and net.core.somaxconn
        listen       8080 default_server deferred reuseport backlog=65535;
        server_name  localhost;

        location / {
            uwsgi_pass unix:/var/tmp/uwsgi.sock;
            include /usr/local/nginx/conf/uwsgi_params;
        }
    }
}
