# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user daemon;

#worker_processes 2;

worker_processes auto;
worker_rlimit_nofile     20480;
worker_priority          0;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include modules/*.conf;

pid logs/nginx.pid;
error_log logs/error.log;

events {
    use epoll;
    # Allow client connections per worker
    worker_connections  8192;
    # off on Performance Test
    multi_accept on;
}


http {


    log_format  main  '$remote_addr - $remote_user [$time_local] $server_name to: $upstream_addr: "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    log_format  upstream_log '$pid , $time_local , $server_name to: $upstream_addr: $cookie_JSESSIONID , $cookie_uid , $upstream_addr , $request_uri';
    log_format  processing_time '$request , $status , [$request_time] ';

    access_log  logs/access.log main;
    include             mime.types;
    default_type        application/octet-stream;

    output_buffers 1 64k;
    postpone_output 1024;
    keepalive_timeout    5;
    keepalive_requests   10000;

    types_hash_max_size 4096;
    tcp_nodelay          on;
    tcp_nopush           on;

    reset_timedout_connection on;
    sendfile     on;
    send_timeout 10;

    client_header_timeout 5s;
    client_body_timeout   10s;
    client_max_body_size  100m;
    #limit_conn limit_per_ip 5;

    charset utf-8;
    server_tokens off;
    server_names_hash_bucket_size 128;

    # Gzip
    gzip                  on;
    gzip_disable    "MSIE [1-6]\.(?!.*SV1)";
    gzip_types      text/plain text/javascript application/x-javascript text/css text/xml application/xml;
    gzip_min_length 1024;
    gzip_buffers 1 16k;

    map $cookie_jsessionid $route_cookie {
        ~.+\.(?P<route>\w+)$ $route;
    }

    # Search the URL for a trailing jsessionid parameter, and store the value after the final ‘.’
    # in a variable named $route_uri
    map $request_uri $route_uri {
        ~jsessionid=.+\.(?P<route>\w+)$ $route;
    }

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.

######################################
# Default , SSL , Virtualhost config
######################################
    include ../conf.d/*.conf;
}
