Skip to content

Instantly share code, notes, and snippets.

@solar
Created November 6, 2012 15:33
Show Gist options
  • Save solar/4025449 to your computer and use it in GitHub Desktop.
Save solar/4025449 to your computer and use it in GitHub Desktop.
install haproxy-dev with supervisord
# Configurations for haproxy
global
maxconn 4096
chroot /var/haproxy
user haproxy
group haproxy
log 127.0.0.1 local0 alert
stats socket /var/haproxy/stats.socket
defaults
mode http
timeout connect 10s
timeout client 30s
timeout server 30s
balance roundrobin
log global
option httplog
frontend http
bind *:80
option forwardfor
option http-server-close
option http-pretend-keepalive
timeout http-request 20s
timeout http-keep-alive 5s
default_backend default
acl path:hoge path_reg ^/hoge(/.*)?$
use_backend nginx if path:hoge
backend default
redirect location http://google.com/
backend nginx
server nx01 nx01:8080 weight 1 maxconn 1024
server nx02 nx02:8080 weight 1 maxconn 1024
[program:haproxy]
command=/usr/local/sbin/haproxy -f /etc/haproxy.conf -n 4096 -N 4096
autostart=true
autorestart=true
user=root
stdout_logfile=/var/log/haproxy/stdout.log
stderr_logfile=/var/log/haproxy/stderr.log
#!/usr/local/bin/zsh
version="1.5"
date="20121127"
# create directories
sudo mkdir -p /var/haproxy /var/log/haproxy /etc/supervisord.d
# create user
sudo groupadd haproxy
sudo useradd -r -g haproxy -M -d /var/haproxy -s /sbin/nologin haproxy
sudo chown haproxy:haproxy /var/haproxy
# download and install
curl -sL http://haproxy.1wt.eu/download/${version}/src/snapshot/haproxy-ss-${date}.tar.gz | tar zx
cd haproxy-ss-${date}/
make PREFIX=/usr/local/haproxy/snapshot-${date} TARGET=linux2628 CPU=native USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1
sudo make PREFIX=/usr/local/haproxy/snapshot-${date} install
cd ../
rm -rf haproxy-ss-${date}
# create symlinks
sudo alternatives \
--install /usr/local/sbin/haproxy haproxy /usr/local/haproxy/snapshot-${date}/sbin/haproxy ${date} \
--slave /usr/local/share/man/man1/haproxy.1 man-haproxy.1 /usr/local/haproxy/snapshot-${date}/share/man/man1/haproxy.1
# put configurations
sudo cp ./haproxy.conf /etc/
sudo cp ./haproxy.ini /etc/supervisord.d/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment