nginx-proxy is a tool that can be defined as “Automated nginx proxy for Docker containers using docker-gen. docker-gen generates reverse proxy configs for nginx and reloads nginx when containers are started and stopped.”. I used nginx-proxy for generating random subdomains for recently spawned docker containers.
I’m developing a data annotation tool for our team. We decided to spawn a container to each annotator. After that, we needed unique and shuffled URLs that anyone should not access by brute forcing.
After few quick searches, I came across with Traefik. It might be good to use that tool with lots of capabilities and definitely solves my problem. However, I didn’t have time to learn something big and new. Then, I found a blog post, “Automated Nginx Reverse Proxy for Docker“, that tells what i want is easily applicable by nginx-proxy. I’m cutting my story in here and let the code itself talks.
Nginx-proxy has following features:
- IPv6 support
- Multiple ports
- Wildcard hosts
- Multiple networks
- SSL support
- Basic authentication support
- … and more.
All you need to do is as simple as following:
- First, run nginx-proxy container.
- Then, run any container you want with -e VIRTUAL_HOST=”” flag.
- nginx-proxy, https://github.com/nginx-proxy/nginx-proxy
- docker-gen, https://github.com/jwilder/docker-gen
- Traefik, https://docs.traefik.io/
- Automated Nginx Reverse Proxy for Docker, http://jasonwilder.com/blog/2014/03/25/automated-nginx-reverse-proxy-for-docker/