Introducing Nginx Proxy Zero

Recently, I've been drawing a lot of inspiration from nginx-proxy. To summarize, nginx-proxy combines docker event-based nginx config generation with automatic nginx reloading. This allows you to define a VIRTUAL_HOST env variable on any container and have it added to the reverse proxy configuration in real time with no additional effort. This saves me a ton of time at work where we host dozens of integrations across several servers, and host as much as 10 different integrations on a single server. There is minimal downtime on deploy as well: just pull the new changes and start a new container with the same virtual host, and nginx-proxy does the rest (make sure to stop the old container though). Since I was doing this kind of deployment a lot, I thought I'd take a shot at automating this process through an api that runs in its own container. From what I've seen, there isn't much out there that fills this sort of niche. You can always host a single-node kubernetes cluster but this introduces a lot of overhead and configuration, definitely not as simple as running a container.

nginx_proxy_zero is my ongoing effort to create this sort of simple, idiomatic interface around deployments on a single instance. It's still rough in terms of features, and there's plenty I want to add to it. For now, there's one endpoint available to you: POST /update_deployment, and the body of your request will look something like this:

      "name": "nginxproxyzero_some-zerodowntime-service_1",
      "network": "nginxproxyzero_default",
      "image": "jwilder/whoami",
      "virtual_host": "whoami.deve"

So, what's happening here? This setup assumes there is already a running container named nginxproxyzero_some-zerodowntime-service_1 and that the intended action is to update this container via a rolling deployment. Zero will pull the new image and start a new container, then perform a health check. When the new container is healthy, it will rename the new container to the name param and stop/remove the old container. The API is a ruby/sinatra app and, imo, is very easy to read and track what's happening with the underlying API.

Are there tools out there like this? Would you find something like this useful or want to contribute to it? If so please reach out on HN or Twitter.

Show Comments