Skip to content

Instantly share code, notes, and snippets.

@ayosec
Created August 9, 2012 13:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayosec/3304435 to your computer and use it in GitHub Desktop.
Save ayosec/3304435 to your computer and use it in GitHub Desktop.
HAProxy basic example
# Simple web server
# Use N_ envvar to identify the process
run lambda {|env|
[ 200, {}, "Ok @ #{ENV["N_"]}"]
}
global
maxconn 4096
#user haproxy
#group haproxy
#daemon
defaults
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
maxconn 1
contimeout 5000
clitimeout 50000
srvtimeout 50000
stats enable
stats auth us3r:passw0rd
frontend graphene
mode http
bind *:8080
acl is_api hdr_beg(Host) api.
acl workper_path path_beg /nodes
acl accountmanager_path path_beg /account
use_backend worker if workper_path is_api
use_backend accountmanager if accountmanager_path is_api
default_backend webpage
backend webpage
server webpage1 localhost:8081 check
backend worker
server webpage1 localhost:8082 check
backend accountmanager
server accountmanager1 localhost:8083 check
$ curl -H "Host: api.graph" -i localhost:8080/account/0
$ curl -H "Host: api.graph" -i localhost:8080/nodes/0
$ curl -i localhost:8080/nodes/0
$ curl -i localhost:8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment