Skip to content

Commit a4f7316

Browse files
DOC: Update the README to use Makefile for Docker images
The build process has been updated to use a Makefile. This patch updates the README to reflect those changes for the Docker images. It also updates the frontend/backends in the example to use `mode http` and removes the `check-ssl` option from the backend servers, which is not needed because they are running over plain HTTP.
1 parent 5c3661b commit a4f7316

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Illustrating the utility of haproxy as a load-balancer is best accomplished usin
1616
1. Build the image:
1717

1818
```shell
19-
docker build -t haproxy .
19+
make build-image
2020
```
2121

2222
2. Start the haproxy image in detached mode and map its secure, dataplane API port (`5556`) and the port used by the load balancer (`8085`) to the local host:
@@ -33,9 +33,9 @@ Illustrating the utility of haproxy as a load-balancer is best accomplished usin
3333
--cert example/client.crt --key example/client.key \
3434
--user client:cert \
3535
-H "Content-Type: application/json" \
36-
-d '{"name": "lb-frontend", "mode": "tcp"}' \
36+
-d '{"name": "lb-frontend", "mode": "http"}' \
3737
"https://localhost:5556/v2/services/haproxy/configuration/frontends?version=1"
38-
{"mode":"tcp","name":"lb-frontend"}
38+
{"mode":"http","name":"lb-frontend"}
3939
```
4040

4141
4. [Bind](https://www.haproxy.com/documentation/dataplaneapi/latest/#tag/Bind) the frontend configuration to `*:8085`:
@@ -55,7 +55,9 @@ Illustrating the utility of haproxy as a load-balancer is best accomplished usin
5555

5656
```shell
5757
$ curl http://localhost:8085
58-
curl: (52) Empty reply from server
58+
<html><body><h1>503 Service Unavailable</h1>
59+
No server is available to handle this request.
60+
</body></html>
5961
```
6062

6163
6. Create a [backend configuration](https://www.haproxy.com/documentation/dataplaneapi/latest/#tag/Backend) and bind it to the frontend configuration:
@@ -66,9 +68,9 @@ Illustrating the utility of haproxy as a load-balancer is best accomplished usin
6668
--cert example/client.crt --key example/client.key \
6769
--user client:cert \
6870
-H "Content-Type: application/json" \
69-
-d '{"name": "lb-backend", "mode":"tcp", "balance": {"algorithm":"roundrobin"}, "adv_check": "tcp-check"}' \
71+
-d '{"name": "lb-backend", "mode":"http", "balance": {"algorithm":"roundrobin"}, "adv_check": "tcp-check"}' \
7072
"https://localhost:5556/v2/services/haproxy/configuration/backends?version=3"
71-
{"adv_check":"tcp-check","balance":{"algorithm":"roundrobin","arguments":null},"mode":"tcp","name":"lb-backend"}
73+
{"adv_check":"tcp-check","balance":{"algorithm":"roundrobin","arguments":null},"mode":"http","name":"lb-backend"}
7274
```
7375

7476
7. Update the frontend to use the backend:
@@ -79,9 +81,9 @@ Illustrating the utility of haproxy as a load-balancer is best accomplished usin
7981
--cert example/client.crt --key example/client.key \
8082
--user client:cert \
8183
-H "Content-Type: application/json" \
82-
-d '{"name": "lb-frontend", "mode": "tcp", "default_backend": "lb-backend"}' \
84+
-d '{"name": "lb-frontend", "mode": "http", "default_backend": "lb-backend"}' \
8385
"https://localhost:5556/v2/services/haproxy/configuration/frontends/lb-frontend?version=4"
84-
{"default_backend":"lb-backend","mode":"tcp","name":"lb-frontend"}
86+
{"default_backend":"lb-backend","mode":"http","name":"lb-frontend"}
8587
```
8688

8789
8. Run two simple web servers in detached mode named `http1` and `http2`:
@@ -99,7 +101,7 @@ Illustrating the utility of haproxy as a load-balancer is best accomplished usin
99101
--cert example/client.crt --key example/client.key \
100102
--user client:cert \
101103
-H "Content-Type: application/json" \
102-
-d '{"name": "lb-backend-server-1", "address": "'"$(docker inspect http1 -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}')"'", "port": 80, "check": "enabled", "check-ssl": "enabled", "maxconn": 30, "verify": "none", "weight": 100}' \
104+
-d '{"name": "lb-backend-server-1", "address": "'"$(docker inspect http1 -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}')"'", "port": 80, "check": "enabled", "maxconn": 30, "verify": "none", "weight": 100}' \
103105
"https://localhost:5556/v2/services/haproxy/configuration/servers?backend=lb-backend&version=5"
104106
{"address":"172.17.0.2","check":"enabled","maxconn":30,"name":"lb-backend-server-1","port":80,"weight":100}
105107
```
@@ -125,15 +127,15 @@ Illustrating the utility of haproxy as a load-balancer is best accomplished usin
125127
--cert example/client.crt --key example/client.key \
126128
--user client:cert \
127129
-H "Content-Type: application/json" \
128-
-d '{"name": "lb-backend-server-2", "address": "'"$(docker inspect http2 -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}')"'", "port": 80, "check": "enabled", "check-ssl": "enabled", "maxconn": 30, "verify": "none", "weight": 100}' \
130+
-d '{"name": "lb-backend-server-2", "address": "'"$(docker inspect http2 -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}')"'", "port": 80, "check": "enabled", "maxconn": 30, "verify": "none", "weight": 100}' \
129131
"https://localhost:5556/v2/services/haproxy/configuration/servers?backend=lb-backend&version=6"
130132
{"address":"172.17.0.3","check":"enabled","maxconn":30,"name":"lb-backend-server-2","port":80,"weight":100}
131133
```
132134
133135
12. Now that both web servers are connected to the load-balancer, use `curl` to query the load-balanced endpoint a few times to validate that both backend servers are being used:
134136
135137
```shell
136-
$ for i in 1 2 3 4; do curl http://localhost:8085 && echo; done
138+
$ for i in {1..4}; do curl http://localhost:8085 && echo; done
137139
Server address: 172.17.0.2:80
138140
Server name: 456dbfd57701
139141
Date: 21/Dec/2019:22:26:51 +0000

0 commit comments

Comments
 (0)