Proof of concept for blue-green upstream proxy with nginx + ngx_http_perl_module.
This method pulls the latest image from Docker Hub. Ready for use as a stateless container proxy for use on container platforms like ECS, EKS
- Set up environment file and docker run
- Print current upstream
- Switch upstream
- Clean up container
Copy sample environment file, modify values to suit, and docker run
# cp .env.sample .env
# docker run -p 80:80 -d --name nginx --env-file ./.env meappy/nginx-blue-green
# docker exec -it nginx /deploy.py -p
Current deploy status: apache:80
# docker exec -it nginx /deploy.py -d green
Current deploy status: apache:81
# docker stop nginx
# docker rm nginx
This method pulls an nginx image from Docker Hub. Docker volume is used with deploy script. Good for use as stateful setup where persistent storage is used.
- Start up nginx + Apache containers
- Setup config.ini and deploy blue or green upstream
- Test
docker-compose up -d
# cp config.ini.sample config.ini
# ./deploy.py -d blue
Current deploy status: blue:8081
# ./deploy.py -p
Current deploy status: blue:8081
# curl -H 'Host: poc' -k -iL http://127.0.0.1
HTTP/1.1 200 OK
Server: nginx/1.15.12
Date: Thu, 23 May 2019 07:19:00 GMT
Content-Type: text/html
Content-Length: 45
Connection: keep-alive
Last-Modified: Mon, 11 Jun 2007 18:53:14 GMT
ETag: "2d-432a5e4a73a80"
Accept-Ranges: bytes
<html><body><h1>It works!</h1></body></html>