Skip to content

Commit

Permalink
add haproxy script for env setup
Browse files Browse the repository at this point in the history
going to try and test this one day
  • Loading branch information
silentpete committed Feb 21, 2018
1 parent 03bd887 commit e50f9b6
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
# nginx-vs-haproxy

## haproxy

haproxy is a great load balancer, but we should stand up an environment and test...

```bash
./run-haproxy.sh
```

Go to: <http://localhost:8080> and/or <http://localhost:8080/stats>
19 changes: 19 additions & 0 deletions haproxy/haproxy.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
global
debug
maxconn 256

defaults
mode http
timeout connect 5s
timeout client 50s
timeout server 50s
stats enable
stats uri /stats

frontend http-in
bind *:80
default_backend servers

backend servers
server s01 apache-01:80 check cookie s01
server s02 apache-02:80 check cookie s02
1 change: 1 addition & 0 deletions html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello to the World!
13 changes: 13 additions & 0 deletions run-haproxy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [[ $(docker network ls | grep network) ]]; then
echo 'found network'
else
echo 'did not find network, creating network'
docker network create network
fi

docker run -dit --name=apache-01 --net=network --log-driver=json-file -v "$CWD/html/":/usr/local/apache2/htdocs/:ro httpd:2.4-alpine
docker run -dit --name=apache-02 --net=network --log-driver=json-file -v "$CWD/html/":/usr/local/apache2/htdocs/:ro httpd:2.4-alpine
docker run -dit --name=haproxy --log-driver=json-file --net=network -v "${CWD}/haproxy/haproxy.cfg":/usr/local/etc/haproxy/haproxy.cfg:ro -p 8080:80 haproxy:1.8-alpine

0 comments on commit e50f9b6

Please sign in to comment.