worker_processes  1;

events {
   worker_connections  1024;
}

http {
   include       mime.types;
   default_type  application/octet-stream;

   log_format  debuglog  '[$time_local] "$request" $status $body_bytes_sent "$upstream_addr ($upstream_status)"';

   access_log  /var/log/nginx/access.debug.log debuglog;
   error_log   /var/log/nginx/errors.debug.log debug;

   sendfile on;
   tcp_nopush on;
   keepalive_timeout 70 30;
   reset_timedout_connection   on;
   
   # Upstreams
   upstream tst {
      server 127.0.0.1:8080 max_fails=3 fail_timeout=60s; # Alive
      server 10.76.0.40:6666 max_fails=3 fail_timeout=60s; # Dead (port not binded)
      server 10.76.0.40:7777 max_fails=3 fail_timeout=60s; # Dead (port not binded)
   }

   server {
      listen   80 default;
      server_name  localhost;

      access_log  /var/log/nginx/access.80.debug.log debuglog;
      error_log   /var/log/nginx/errors.80.debug.log debug;

      proxy_connect_timeout 5s;
      location /tst {
         proxy_pass http://tst;
      }
   }

   server {
      listen 8080;
      server_name _;

      access_log  /var/log/nginx/access.8080.debug.log debuglog;
      error_log   /var/log/nginx/errors.8080.debug.log debug;
     
      location / {
         default_type text/plain;
         empty_gif;
      }
   } 
}
