A docker image to start a load balancer (with sticky module) using Nginx.
Since we use the third-party module (sticky), the Nginx must be compiled from the source. To reduce the image size, we use alpine as basic image. The built image size is 194MB which is acceptable now.
-
Pull the docker image:
docker pull cuyu/nginx-lb
OR you can git clone this project and build the docker image at local:
docker build -t nginx-lb .
-
Create a file named
hosts
, with specific hostnames (include port) in it. For example:example-host1:8000 example-host2:8000 example-host3:8000
-
Run the docker container:
docker run --rm --name lb -v /YOUR_OWN_PATH/hosts:/usr/local/hosts -p 8080:80 cuyu/nginx-lb
Then open
http://localhost:8080
, you will see the target web page.OR if you want to proxy with ssl:
docker run --rm --name lb -v /YOUR_OWN_PATH/hosts:/usr/local/hosts -p 8080:80 cuyu/nginx-lb -ssl
Then open
https://localhost:8080
, you will see the target web page.
Support proxy https web pages (i.e. enable ssl).Use smaller base image (maybe install g++ and wget on a basic ubuntu image).