Best Ubuntu+Nginx Reverse Proxy setup?

Hi Everyone!

I’m looking for a Fly optimized nginx Reverse proxy set up. I know I can just use a Ubuntu+Nginx docker image, or even just build one myself, but I’m looking for any best practices or tips on how best to configure Fly as a caching reverse proxy for my project.

I’m using flyctl in production already and am familiar with all it provides. We’re using the Fly Certificates for SSL generation as well, so no need to generate SSL inside the image.

Side topic: Any recommendation on using Caddy as a Caching Reverse Proxy instead of Nginx?

Thanks!

We have a very basic nginx example here: https://github.com/fly-examples/edge-nginx

Now we think that we should have good examples for larger nginx use cases, probably using OpenResty: https://fly.io/docs/app-guides/openresty-nginx-plus-lua/

This is an important part of a full stack image service, too. I’d rather write TypeScript but nginx + lua is incredibly powerful.

I’m curious if there are any better alternatives for this now, or how complex an OpenResty Dockerfile/fly.toml might be :thinking:

Totally agree TypeScript proxy logic writing would be awesome. Even some WebWorkers/Wasm limited subset type deal could be interesting.

If you need a simple reverse proxy you can use Fly-Replay and let fly proxy handle that for you.

I wrote an example of how to do that with a certain path here: How to route certain paths to another Fly app without a reverse proxy? Meet Fly-Replay

If you need more complex caching that could also be an interesting starting point. If anything, tell us more about your use case.

Thank you, that did the trick, super cool tool! For some reason the nginx pass approach couldn’t keep up with the traffic (requests were failing on and off) but replay worked quite well. Maybe something to do with a concurrency setting that needed changing.

2 Likes

I’m glad it’s working well with Fly-Replay!