random-image-server
This project is just an Nginx server that shows one random image from a directory, picking a different one on every page load. Point it at a folder, visit the page, get an image.
I haven’t actually deployed this anywhere yet. I was thinking it would be funny to collect a massive amount of individual instances of one meme, and then run a site that serves them up randomly, one at a time.
The whole thing is a Lua block inside the Nginx config. On each request it scans the image directory with LuaFS, picks a random file from what it finds, and emits a small HTML page displaying it centered on a black background, with a cache-busting query parameter so the browser doesn’t just hand back the previous image. There’s no application behind Nginx, and no index or database of the images - adding a picture to the directory is the entire deployment step.
Using LuaFS instead of shelling out to ls is the main reason it
stays reasonable to expose: nothing user-controlled ever reaches a
shell. Beyond that it runs as the unprivileged nobody user, rate
limits by IP (30 requests a minute by default), sanitizes paths so
nothing outside the image directory can be reached, only serves a
whitelist of image extensions, and sets the usual security headers.
It deploys either with Docker Compose or with an install script that
handles the Nginx and Lua packages directly on Debian- or Fedora-based
systems. Dimensions, port, rate limit, and hostname all come from
.env. There’s a small attribution tooltip in the corner, which you
could remove or point at something else.
The code is here on GitHub.