Nginx Reverse Proxy + Imaginary in a single image

Building off a few previous threads, I wanted to kick start the discussion of building a Docker image of an nginx reverse proxy setup that also automatically bundles imaginary.

Ref Threads:

The Goal

The goal of this project is to build a Dockerfile intended to be deployed via Fly that covers the following requirements:

  • Single Docker image
  • nGinx Reverse Proxy for common HTTP requests (most HTML, JS+CSS, etc)
  • Images served through the proxy are passed through Imaginary, pulled from the same backend as the Proxy

Posting this here to put this together in public and solicit input & feedback from this community. I am most creative when I can bounce ideas off of others :slight_smile:

Here’s my starting point from another project: Example Reverse Proxy nginx.conf · GitHub

Is this interesting?

Any thoughts on this use case?

We run an app that bundles redis and a custom redis proxy into a single image. Here’s a (simplified) gist that shows how we got supervisord to manage the two processes.

It’s likely you’ll need to build an image from scratch with nginx + imaginary since the official images have scripts that conflict with each other and/or don’t play nicely with supervisord. supervisord will make sure both services are running, but you might also want health checks with fly to ensure both services are alive and accepting traffic.

1 Like

Based on what I’ve seen elsewhere, I would probably run nginx and improxy/imaginary as separate applications. The image transforms are very CPU intensive and it’s likely better to scale them up/down separately than nginx.

Nginx is relatively lightweight, and it’s helpful to keep a fixed number of them running if you want to do disk based caching.

I would also start with OpenResty instead of vanilla nginx:

OpenResty gives you easy Lua scripting, and almost no one wants to expose image transform URLs directly. Being able to write a little bit of Lua to add custom logic is helpful.