Skip to content

Instantly share code, notes, and snippets.

@doomhz
Created June 11, 2012 15:55
Show Gist options
  • Save doomhz/2910803 to your computer and use it in GitHub Desktop.
Save doomhz/2910803 to your computer and use it in GitHub Desktop.
haproxy config
# Install HAProxy
cd ~
wget http://haproxy.1wt.eu/download/1.5/src/devel/haproxy-1.5-dev6.tar.gz
tar xzf haproxy-1.5-dev6.tar.gz
cd haproxy*
make install
# HAProxy config
mkdir /etc/haproxy
sudo vim /etc/haproxy/haproxy.cfg
# Paste this at the end
global
maxconn 4096
defaults
mode http
frontend all 0.0.0.0:80
timeout client 86400000
default_backend www_nodejs
acl is_websocket hdr(upgrade) -i websocket
acl is_websocket hdr_beg(host) -i ws
use_backend www_nodejs if is_websocket
backend www_nodejs
option forwardfor
timeout server 86400000
timeout connect 4000
server nodejs 127.0.0.1:3000 weight 1 maxconn 10000 check
# Test haproxy config
haproxy -c -f /etc/haproxy/haproxy.cfg
# Run HAProxy
haproxy -f /etc/haproxy/haproxy.cfg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment