Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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:

share|improve this question
1  
nginx does have an embedded Lua scripting language; it should be possible to do this. –  Michael Hampton Dec 27 '13 at 9:16

2 Answers 2

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

http://sosedoff.com/2012/06/11/dynamic-nginx-upstreams-with-lua-and-redis.html

share|improve this answer
1  
Funny, this is a link to my own blog post :) –  Dan Sosedoff Aug 15 '14 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:

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.