Created
August 9, 2012 13:59
-
-
Save ayosec/3304435 to your computer and use it in GitHub Desktop.
HAProxy basic example
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
# Simple web server | |
# Use N_ envvar to identify the process | |
run lambda {|env| | |
[ 200, {}, "Ok @ #{ENV["N_"]}"] | |
} |
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
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 |
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
$ 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