daemon off;
master_process off;


user dibs;
worker_processes 12;
error_log logs/error.log  debug;
pid logs/nginx.pid;
debug_points abort;

events {
	worker_connections  1024;
}

http {
	include mime.types;
	etag off;
	client_header_timeout 10;
	client_body_timeout 10;

	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_pass_header       X-Server-Name;
#	proxy_set_header 	Accept-Encoding "";
#	proxy_pass_header       Location;

#	proxy_buffering   off;
#	client_max_body_size    10m;
#	client_body_buffer_size 128k;
	proxy_connect_timeout   300;
	proxy_send_timeout      300;
	proxy_read_timeout      300;
#	proxy_buffers           32 4k;
	proxy_cache_path /usr/local/nginx/cache keys_zone=static-data:25m;
		#proxy_set_header X-Forwarded-For $remote_addr;
		#proxy_set_header X-WAF $hostname;
	ssl_session_cache shared:SSL:10m;
	keepalive_timeout 75s;
	#Gatekeeper:
#		limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
#		limit_req_zone $binary_remote_addr zone=twenty:10m rate=20r/s;
#		limit_req_zone $binary_remote_addr zone=fifty:10m rate=50r/s;
#		limit_req_log_level info;
#		limit_req_status 429;
	#Gatekeeper end
	#match statuswaf {
        #	#status 200;
	#	#header Content-Type = text/html;
	#	body ~ "WAF";
	#}
	upstream X3cluster1-port880 {
		#zone X3cluster1-port880 10m;
		ip_hash;
		server webserver11:880;
		server webserver12:880 down;
	}
	upstream X3cluster1-port8043 {
	        ip_hash;
	        server webserver11:1500;
	        #server webserver11:8043;
		server webserver12:8043 down;
	}
	upstream X3cluster1-port8044 {
	       least_conn;
	        server webserver11:8044;
		server webserver12:8044 down;
	}

	#Health check for LoadBalancer.org:
	server {
        	#listen 5555;
        	listen 5556;
		index  check.txt;
	        location /check.txt {
        		root   /usr/local/netsite;
        	}
	}
        server {
                listen 80;
	        server_name webserver.architrade.com;
#		limit_req zone=twenty burst=5;
		location ~* ((images|paydeco)\/.+$|\.(jpg|png|gif|jpeg|css|js)$) {
			proxy_cache static-data;
			#proxy_buffering           on;
			proxy_cache_valid 200 304 120m;
			proxy_cache_valid 404      720m;
			#expires 864000;
			proxy_pass http://X3cluster1-port880;
		}		
                location / {
               #         ModSecurityEnabled on;
               #         ModSecurityConfig modsecurity.conf;
                        proxy_pass http://X3cluster1-port880;
		}
        }
	server {
		listen 443 ssl;
	        server_name webserver.architrade.com;
        	ssl_certificate ssl/cert.crt;
	        ssl_certificate_key com.key;
		ssl_ciphers  ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM;
		#ssl_prefer_server_ciphers  on;
	        location / {
			ModSecurityEnabled on;
			ModSecurityConfig modsecurity.conf;
			proxy_pass http://X3cluster1-port8043;
			proxy_redirect off;
                }
	}
}
