Created
November 20, 2019 12:56
-
-
Save vpack/694a9b22d9f9bdd90add27c2625f4495 to your computer and use it in GitHub Desktop.
hap
This file contains hidden or 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
cat haproxy.cfg | |
#--------------------------------------------------------------------- | |
# Global settings | |
#--------------------------------------------------------------------- | |
global | |
log 127.0.0.1 local2 | |
pidfile /var/run/haproxy.pid | |
maxconn 2000 | |
daemon | |
#--------------------------------------------------------------------- | |
# common defaults that all the 'listen' and 'backend' sections will | |
# use if not designated in their block | |
#--------------------------------------------------------------------- | |
defaults | |
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 | |
option httpclose | |
option httplog | |
#option forwardfor | |
mode http | |
frontend http-in | |
bind *:80 | |
mode http | |
acl is_green hdr_dom(host) -i green | |
acl is_blue hdr_dom(host) -i blue | |
acl is_red hdr_dom(host) -i red | |
use_backend green if is_green | |
use_backend blue if is_blue | |
use_backend blue if is_red | |
#default_backend red | |
backend green | |
balance roundrobin | |
option log-health-checks | |
server green green.mynet:80 check | |
backend blue | |
balance roundrobin | |
option log-health-checks | |
server blue blue:80 check | |
backend red | |
balance roundrobin | |
option log-health-checks | |
server red red:80 check | |
listen stats | |
bind :81 | |
mode http | |
stats enable | |
timeout connect 10s | |
timeout client 1m | |
timeout server 1m | |
stats hide-version | |
stats realm Haproxy\ Statistics | |
stats uri / | |
stats auth stats:SMqzeA5GJIYs | |
[venkat@admins-MacBook-Pro-2 haproxy $ |
This file contains hidden or 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
cat Makefile | |
net: | |
docker network create --driver overlay --attachable mynet | |
n1: | |
docker run -d --net mynet --name green nginx | |
n2: | |
docker run -d --net mynet --name blue nginx | |
n3: | |
docker run -d --net mynet --name red nginx | |
h: | |
docker rm -f hap || echo done | |
docker run -d -v $$PWD/haproxy.cfg://usr/local/etc/haproxy/haproxy.cfg -p 80:80 --net mynet --name hap haproxy | |
sleep 1 | |
docker logs hap | |
j: | |
docker run -d -v $$PWD/Makefile:/Makefile --net mynet --name jumpbox alpine:3.10 tail -f /dev/null | |
cp: | |
docker cp green.html green:/usr/share/nginx/html/index.html | |
docker cp blue.html blue:/usr/share/nginx/html/index.html | |
docker cp red.html red:/usr/share/nginx/html/index.html | |
bash: | |
docker exec -it jumpbox ash | |
test: | |
curl -v -H "HOST: green.me" localhost | |
curl -H "HOST: blue.me" localhost | |
tr: | |
wget -O - --header "Host: red" hap | |
curl -H"Host: blue" hap | |
curl -H"Host: green" hap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment