haproxy配置文件模板

haproxy配置文件模板
global # Log to syslog log ${hosts:syslog}:${ports:syslog} local2 # Max connections maxconn ${limits:open-files} # Number of processes nbproc 1 defaults # Use HTTP connections mode http # close HTTP keep-alives to make header analysis work across keep-alives option httpclose # Remove requests from the queue if people press stop button option abortonclose # Try to connect this many times on failure retries 3 # If a client is bound to a particular backend but it goes down, # send them to a different one option redispatch # Expose a URL to make it easier to check if haproxy is up monitor-uri /_haproxy_ping_ # Default timeouts timeout connect 7s timeout queue 300s timeout client 300s timeout server 300s # Enable status page at this URL, on the port HAProxy is bound to listen stats ${hosts:haproxy}:${ports:haproxy-stats} stats enable stats uri / stats refresh 5s stats realm Haproxy statistics # Default front-end frontend loadbalancer # Bind to the given address bind ${hosts:haproxy}:${ports:haproxy} # Log errors in HTTP logging format log global option httplog option dontlog-normal # Access rules # Check that we have at least one node up in each cluster acl default_cluster_up nbsrv(default) gt 0 # Routing use_backend default if default_cluster_up default_backend panic # Backend for all nodes. backend default # Load balance based on number of connections balance leastconn # Record where we've been rspadd X-Cluster:\ default # Note: The maxconn values here match the ZServer thread count. This means requests pile up # in HAProxy until Zope's ready, instead of getting stuck in Zope. server instance1 ${hosts:instance1}:${ports:instance1} check rise 1 weight 50 maxconn 4 server instance2 ${hosts:instance2}:${ports:instance2} check rise 1 weight 50 maxconn 4 server instance3 ${hosts:instance3}:${ports:instance3} check rise 1 weight 50 maxconn 4 server instance4 ${hosts:instance4}:${ports:instance4} check rise 1 weight 50 maxconn 4 # This is hit only if none of the other clusters are working backend panic balance leastconn # Panic!!!!111eleven!! redirect location ${urls:fallback} drop-query
设置