#user  root;
worker_processes  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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
     
    upstream FR.com {
        server 10.120.133.95:8080 max_fails=10 fail_timeout=100s;
        server 10.120.133.96:8080 max_fails=10 fail_timeout=100s;
       #ip_hash;
    }

    upstream WBS.com { 
        server 10.120.133.95:38888 max_fails=10 fail_timeout=100s;
	    server 10.120.133.96:38888 max_fails=10 fail_timeout=100s;
        ip_hash;
    }

    server {
        listen       80;
        server_name  localhost;
        underscores_in_headers on;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        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_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_connect_timeout    20;
            proxy_read_timeout       1000;
            proxy_send_timeout       300;
        }

        #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 {  
        listen 38889;              
	    server_name localhost;
        location / { 
             proxy_http_version 1.1;       
             proxy_pass http://WBS.com;
             proxy_connect_timeout 20;
             proxy_read_timeout 1000;
             proxy_send_timeout       300;
		     proxy_set_header Upgrade $http_upgrade;
		     proxy_set_header Connection "upgrade";
             }
        }
}
