#user  root;
worker_processes  auto;
#worker_cpu_affinity  auto;

error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for" $upstream_addr';                 
    access_log  off;
    #access_log  logs/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65s;
    types_hash_max_size 2048;
    #gzip  on;
    #gzip_disable "MSIE [1-6].";
    client_header_buffer_size    512k;
    large_client_header_buffers  4 512k;
    client_max_body_size 100M;
     
    upstream FR.com {
        server 192.168.61.250:8080 max_fails=15 fail_timeout=300s;
        server 192.168.61.251:8080 max_fails=15 fail_timeout=300s;
        
#<---------------ngx_healthcheck_module--------------->#
        #check interval=3000 rise=2 fall=2 timeout=1000 type=http;
        #check_http_send "GET /webroot/decision/system/info HTTP/1.0\r\n\r\n";
        #check_http_expect_alive http_2xx http_3xx;
#<---------------ngx_healthcheck_module--------------->#
    }
    
    upstream WBS.com { 
        server 192.168.61.250:38888 max_fails=15 fail_timeout=300s;
	    server 192.168.61.251:38888 max_fails=15 fail_timeout=300s;
	    ip_hash;
    }
    server {
        listen       80;
        server_name  localhost;
        underscores_in_headers on;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;

#<---------------Nginx upstream status monitor--------------->#
        #location /status {
        #    healthcheck_status html;
        #}
#<---------------Nginx upstream status monitor--------------->#

        location / {
            proxy_http_version 1.1;
            proxy_pass http://FR.com;
            proxy_next_upstream http_500 http_502 http_503 http_504 http_403 http_404 http_429 error timeout invalid_header non_idempotent;
            #proxy_next_upstream_timeout 0;
            #proxy_next_upstream_tries 0;
            proxy_redirect off;
            proxy_set_header Host $host:$server_port;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

	        proxy_set_header Connection "";
            #proxy_buffering off;
            #proxy_buffer_size     64k;
            #proxy_buffers         32 64k;
            #proxy_busy_buffers_size 64k;
            
            proxy_connect_timeout    60;
            proxy_read_timeout       120;
            proxy_send_timeout       120;
        }

        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    server {  
        #FineReport:38889 FineBI:48889
        listen 38889;
       #listen 48889;
	    server_name localhost;
        location / { 
             proxy_http_version 1.1;
             proxy_pass http://WBS.com;
             proxy_connect_timeout 60;
             proxy_read_timeout 120;
             proxy_send_timeout 120;
             
		     proxy_set_header Upgrade $http_upgrade;
		     proxy_set_header Connection "upgrade";
             }
        }
} 