Created
December 5, 2010 18:41
-
-
Save taf2/729335 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#--------------------------------------------------------------------- | |
# Example configuration for a possible web application. See the | |
# full configuration options online. | |
# | |
# http://haproxy.1wt.eu/download/1.3/doc/configuration.txt | |
# | |
#--------------------------------------------------------------------- | |
#--------------------------------------------------------------------- | |
# Global settings | |
#--------------------------------------------------------------------- | |
global | |
log 127.0.0.1 local2 | |
pidfile log/haproxy.pid | |
maxconn 4000 | |
daemon | |
#--------------------------------------------------------------------- | |
# common defaults that all the 'listen' and 'backend' sections will | |
# use if not designated in their block | |
#--------------------------------------------------------------------- | |
defaults | |
mode http | |
log global | |
option dontlognull | |
option redispatch | |
timeout connect 10000 # default 10 second time out if a backend is not found | |
timeout client 300000 | |
timeout server 300000 | |
maxconn 60000 | |
retries 3 | |
#--------------------------------------------------------------------- | |
# main frontend which proxys to the backends | |
#--------------------------------------------------------------------- | |
frontend main *:9000 | |
option forwardfor | |
option httpclose | |
option httplog | |
acl url_static path_beg -i /static /images /javascript /stylesheets /flash /system | |
use_backend static if url_static | |
default_backend rails_app | |
# acl is_websocket hdr(Upgrade) -i WebSocket | |
# acl is_websocket hdr_beg(Host) -i ws | |
# use_backend web_pushback if is_websocket | |
frontend websock *:8888 | |
option tcplog | |
mode tcp | |
timeout client 86400000 | |
default_backend web_pushback | |
#--------------------------------------------------------------------- | |
# static backend for serving up images, stylesheets and such | |
#--------------------------------------------------------------------- | |
backend static | |
balance roundrobin | |
server static 127.0.0.1:4000 check | |
#--------------------------------------------------------------------- | |
# round robin between app servers | |
#--------------------------------------------------------------------- | |
backend rails_app | |
balance roundrobin | |
server app1 127.0.0.1:4000 check | |
# TODO: can/should we have 2 nginx's one per box? | |
#--------------------------------------------------------------------- | |
# round robin between push servers (my test) | |
#--------------------------------------------------------------------- | |
backend web_pushback | |
balance roundrobin | |
# timeout server 86400000 | |
# websocket support or long poll support | |
timeout queue 5000 | |
timeout server 86400000 | |
server app1 127.0.0.1:4012 maxconn 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
root=`pwd` | |
# development | |
HAVRS=haproxy-ss-20101202 | |
# stable | |
#HAVRS=haproxy-1.4.10 | |
HABIN=$root/$HAVRS/haproxy | |
HACFG=$root/config/haproxy-dev.cfg | |
HAPID=$root/log/haproxy.pid | |
check() { | |
$HABIN -c -V -f $HACFG | |
} | |
start() { | |
if [ ! -f $HAPID ]; then | |
$HABIN -f $HACFG | |
retval=$? | |
echo "started: $retval" | |
else | |
echo "already running check $HAPID" | |
exit 1 | |
fi | |
} | |
stop() { | |
if [ -f $HAPID ]; then | |
kill `cat $HAPID` | |
retval=$? | |
[ $retval -eq 0 ] && rm -f $HAPID | |
echo "stopped: $retval" | |
else | |
echo "no pid file: $HAPID" | |
fi | |
} | |
restart() { | |
stop | |
start | |
} | |
case "$1" in | |
start|stop|check|restart) | |
$1 | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|check|restart}" | |
exit 2 | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment