The NGINX reverse proxy for development environments in Docker containers.
Because docker-compose dev environments can be tricky when it comes to https, port numbers, hostnames, multiple layers of VMs and getting all that to line up nicely.
Your Browser -> docker-machine
-> nginx -> yourcontainer
- We use NGINX to accept all requests over SSL using a self-signed certificate.
- We update
sites-enabled/default
to specify our "upstream" hosts.- An upstream host is your web application running on another container.
- NGINX will forward requests directly to the correct container and return the result.
- Currently, all requests are performed over SSL.
- If you don't want SSL, then update sites-enabled/default:
- change this
proxy_pass https://$host;
- to this:
proxy_pass http://$host;
- change this
- Add upstream configs to
sites-enabled/*
to match your proxy needs.
## file: sites-enabled/somecontainer
upstream somecontainer {
server somecontainer:443;
}
- Update your
/etc/hosts
to match$(docker-machine ip) somecontainer
- build via:
docker build -t myproj/nginx:$(date +"%Y%m%d") .
- Use in your docker-compose.yml
...
nginx:
image: myproj/nginx:1234567890
volumes:
- nginx/sites-enabled:/etc/nginx/sites-enabled
ports:
- 443:443
docker-compose up
- Navigate to https://somecontainer/
- ???
- PROFIT!!!