global
	maxconn	280000
	nbproc 	3
	user 	haproxy
	group 	haproxy
	chroot  /var/lib/haproxy
	stats 	socket    /var/run/haproxy.sock

defaults
	mode    http
	balance roundrobin

	maxconn                 275000
	timeout connect         10000
	timeout server          50000
	timeout client          50000

	timeout	http-keep-alive	5s
	timeout	http-request	15s
	
	retries 3
	option  redispatch
	option  abortonclose
	option 	tcp-smart-accept
	option 	tcp-smart-connect
	#option	splice-auto

listen stats self.prv:12001
	stats   enable
	stats	uri 	/

frontend frnt_s_cCM_80
	bind self.prv:8083
	bind portable.0:80
	
	option http-server-close
	option forwardfor
	
	acl invalid_calls		hdr_end(host) -i  cdn1.bg.xoxoCM
	acl invalid_calls		hdr_end(host) -i  cdn.bitG.com
	http-request deny if invalid_calls

	acl is_wp7      		hdr_sub(xcxbxzwp7) -i xcxbxzgzip
	reqadd          		Accept-Encoding:\ gzip  if is_wp7

	acl is_cacheable				path_end	.xml .json
	acl is_cacheable_1				path_end	launcher.php launcher_series.php
	acl is_cacheable_1				path_beg	/cCM-xAdxd/news/index
	acl is_cacheable_1				path_beg	/cCM-xAdxd/native-ads	/xcxbxzios/native-ads
	acl is_cacheable_2				path_beg	/cCM-xAdxd/series /cCM-xAdxd/gallery
	acl is_cacheable_2				path_beg	/xcxbxzios/match  /xcxbxzios/gallery /xcxbxzios/stats 
	acl is_cacheable_2				path_beg	/statsbuzz/getdata /xAdxd/archive
	acl is_cacheable_img			path_end	.png
	acl is_cacheable_img			path_beg	/di/url/ /stats/img/
	acl is_cacheable_img			path_beg	/i/news/ /i/gallery/ /i/stats/ /i/flags/ /i/images/
	acl xMBxd_url					path_sub	/launcher/ 
	
	acl is_dynamic					path_end	.php
	
	acl	url_ads_SB				path_beg	/xAxdxs/units/xMBxd/
	acl url_ads_SB_varnish  	path_beg    /xAxdxs/units/onebox/
	acl	url_analytics  				path		/ga.php
	
	acl	url_ads_server				path_beg	/xAxdxs/units/xMBxd/xAdxd/xAdxd.strip.
	acl	url_ads_server				path_beg	/xAxdxs/units/xMBxd/strips/strip.
	acl	url_ads_server				path		/xAxdxs/units/xMBxd/iphone/tracker.php
	acl	url_nginx					path        /xAxdxs/units/xMBxd/iphone/nielsen.php
	acl	url_nginx					path        /xAxdxs/units/xMBxd/xAdxd/nielsen.php
	acl	url_nginx					path        /xcxbxzios/tracker/nielsen
	acl	url_ads_server				path		/xAxdxs/units/xMBxd/strips/update.php
	acl	url_ads_server				path		/xAxdxs/units/xMBxd/xAdxd/tracker.php
	acl	url_ads_server				path		/xAxdxs/test-ip
	
	acl	url_xAdxd_ads_free_ads	path		/api/xAdxd/ads-free-registration 
	acl	url_xAdxd_ads_free_logs	path		/api/xAdxd/ads-free-access-logs	/api/xAdxd/ads-free-error-logs
	
	
	use_backend b_xoxoxMP_cache_img		if is_cacheable_img
	use_backend b_xoxoxMP_cache			if is_cacheable
	use_backend b_xoxoxMP_cache_1			if is_cacheable_1
	use_backend b_xoxoxMP_cache_2			if is_cacheable_2
	use_backend b_usra_log_engines		if url_analytics
	use_backend b_xoxoxMP_nginx			if url_nginx
	use_backend b_ads_server			if url_ads_server
	use_backend b_ads_SB_haproxy	if url_ads_SB
	use_backend b_ads_SB_varnish	if url_ads_SB_varnish
	use_backend b_apache				if is_dynamic
	use_backend xMBxd_haproxy			if xMBxd_url
	use_backend xAdxd_adsfree_log		if url_xAdxd_ads_free_logs
	use_backend xAdxd_adsfree_ads		if url_xAdxd_ads_free_ads

	default_backend b_cb_xxsnd


frontend frnt_log_engines_http
	bind self.prv:16220
	mode http
	
	default_backend b_usra_log_engines

listen f_ads_pool self.prv:16910
	option forwardfor
	option http-server-close
	default_backend b_ads_server

backend b_cb_xxsnd
	server	nginx_xxPS	xxPS.prv:80	check weight 3

backend b_xoxoxMP_cache
	reqirep ^Host:\  Host:\ xxsnd.xoxoCM	
	#rspadd 	Cache-Control:\ no-cache
	#rspadd 	Pragma:\ no-cache
	
	server 	varnish_xoxS31		xoxS31.prv:6081		check weight 3
	server 	varnish_xoxS0		xoxS0.prv:6081		check weight 3
	server 	varnish_xoBO		xoBO.prv:6081	check weight 3 
	server 	varnish_UL		UL.prv:6081		check weight 3 backup
	server 	varnish_Au		Au.prv:6081		check weight 3 backup
	server 	varnish_USR		USR.prv:6081		check weight 3 backup
	server 	varnish_TU		TU.prv:6081		check weight 3 backup
	
backend b_xoxoxMP_cache_1
	reqirep ^Host:\  Host:\ xxsnd.xoxoCM	
	#rspadd 	Cache-Control:\ no-cache
	#rspadd 	Pragma:\ no-cache
	
	server 	varnish_UL		UL.prv:6081		check weight 3 
	server 	varnish_Au		Au.prv:6081		check weight 3 
	server 	varnish_xoBO		xoBO.prv:6081	check weight 3 backup
	server 	varnish_xoxS31		xoxS31.prv:6081		check weight 3 backup
	server 	varnish_USR		USR.prv:6081		check weight 3 backup
	server 	varnish_TU		TU.prv:6081		check weight 3 backup

backend b_xoxoxMP_cache_2
	reqirep ^Host:\  Host:\ xxsnd.xoxoCM	
	#rspadd 	Cache-Control:\ no-cache
	#rspadd 	Pragma:\ no-cache
	
	server 	varnish_TU		TU.prv:6081		check weight 3 
	server 	varnish_USR		USR.prv:6081		check weight 3 backup
	server 	varnish_UL		UL.prv:6081		check weight 3 backup
	server 	varnish_xoBO		xoBO.prv:6081	check weight 3 backup
	server 	varnish_xoxS31		xoxS31.prv:6081		check weight 3 backup
	server 	varnish_Au		Au.prv:6081		check weight 3 backup

backend b_xoxoxMP_cache_img
	reqirep ^Host:\  Host:\ xxsnd.xoxoCM	
	#rspadd 	Cache-Control:\ no-cache
	#rspadd 	Pragma:\ no-cache
	
	server 	varnish_xoxS32		xoxS32.prv:6081		check weight 3 
	server 	varnish_TU		TU.prv:6081		check weight 3 
	server 	varnish_USR		USR.prv:6081		check weight 3 
	server 	varnish_UL		UL.prv:6081		check weight 3 backup
	server 	varnish_xoBO		xoBO.prv:6081	check weight 3 backup
	server 	varnish_xoxS31		xoxS31.prv:6081		check weight 3 backup
	server 	varnish_Au		Au.prv:6081		check weight 3 backup

	
backend b_xoxoxMP_nginx
	server nginx_TU		TU.prv:80			check weight 3
	server nginx_USR		USR.prv:80				check weight 3
	server nginx_Au		Au.prv:81			check weight 3 backup
	#server Au_ads		Au.prv:16910		check weight 3 backup


backend b_ads_server
	option forwardfor header X-xcxbxz-forwarded
	server ads_server_pool	apache.prv:16391 check weight 1 slowstart 5000 maxconn 150
	
backend b_m_ads_server
	option forwardfor header X-xcxbxz-forwarded
	timeout connect 30000

	server ads_server_pool	apache.prv:16391 check weight 1 slowstart 5000 maxconn 150


backend b_usra_log_engines
	option forwardfor header X-xcxbxz-forwarded
	
	server log_engine_pool apache.prv:16322 check weight 1 slowstart 5000
	
backend xAdxd_adsfree_log
	option forwardfor header X-xcxbxz-forwarded
	server logengine_1_Au Au.prv:16221 check weight 1 slowstart 5000

backend xAdxd_adsfree_ads
	option forwardfor header X-xcxbxz-forwarded
	server ads_1_Au Au.prv:16911 check weight 1 slowstart 5000
	server ads_2_Au Au.prv:16912 check weight 1 slowstart 5000
	server ads_3_Au Au.prv:16913 check weight 1 slowstart 5000
	server ads_4_Au Au.prv:16914 check weight 1 slowstart 5000
	server ads_5_Au Au.prv:16915 check weight 1 slowstart 5000


	
backend b_apache
	timeout connect 30000
	server xxPS_apache	apache.prv:8075 check maxconn 250 weight 3
	
backend b_ads_SB
	option forwardfor header X-xcxbxz-forwarded
	reqirep ^Host:\  Host:\ ads.xoxoCM
	
	server SB_apache	SB.prv:8080 check weight 3


backend b_ads_SB_nginx
	option forwardfor header X-xcxbxz-forwarded
	reqirep ^Host:\  Host:\ ads.xoxoCM

	server SB_nginx   SB.prv:80 check weight 3

backend b_ads_SB_haproxy
	option forwardfor header X-xcxbxz-forwarded
	reqirep ^Host:\  Host:\ ads.xoxoCM

	server SB_haproxy   SB.prv:8081 check weight 3
		
backend xMBxd_haproxy
	option forwardfor header X-xcxbxz-forwarded
	reqirep ^Host:\  Host:\ m.xoxoCM
	
	server apache_haproxy   apache.prv:8086 check weight 3

backend b_ads_SB_varnish
	option forwardfor header X-xcxbxz-forwarded
	reqirep ^Host:\  Host:\ ads.xoxoCM

	server SB_varnish    SB.prv:6081 check weight 3
