I was experimenting with dynamic upstream configuration for nginx and cant find any good solution to implement upstream configuration from third-party source like redis or mysql.

The idea behind it is to have a single file configuration in primary server and proxy requests to various app servers based on environment conditions. Think of dynamic deployments where you have X servers that are running Y workers on different ports. For instance, i create a new app and deploy. App manager selects a server and then rolls out a worker (Ruby/PHP/Python) and then reports the ip:port to the central database with status "up". At this time when i go to the given url nginx should proxy all requests to the specified ip:port upstream. The whole thing is pretty similar to what heroku does, except this proof-of-concept is not supposed to be production ready, mostly for internal needs.

The easiest solution i found was using resolver with ruby-based DNS server. It works, nginx gets the IP address correctly, but the only problem is that you cant define port number for that IP.

Second solution (which i havent tried yet) is to roll something else as a proxy server, maybe written in Erlang. In this case we need to use something to serve static content.

Any ideas how to implement this in more flexible and stable way?

P.S. Some research options:

  • 1
    nginx does have an embedded Lua scripting language; it should be possible to do this. Commented Dec 27, 2013 at 9:16

2 Answers 2


Here is exactly as Michael Hampton referenced - implementing dynamic upstream using Lua


  • 4
    Funny, this is a link to my own blog post :) Commented Aug 15, 2014 at 4:16

It looks like the previous answer, by Dan is more in line with what you're thinking.

But I did write a node.js-based reverse proxy which would allow this to be achieved easily:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .