Handling redirects among upstream servers

zappa nginx-forum at nginx.us
Fri Nov 7 10:11:44 UTC 2014


I'm trying to configure Nginx to access a cluster of application servers
using a simple proxy with multiple application servers in the upstream. The
application servers use a REST api for object storage and retrieval, and use
301 redirects among the nodes of the cluster for load balancing. A client
can connect to server A, then get a redirect to server B, where the request
will be handled.

This fails when nginx is used as a proxy in this case:

- the client connects through the proxy and gets connected to server A

- A returns a 301 with one of the other servers in the Location header

- Nginx rewrites the location header, so information about which node the
client is supposed to connect to is lost

Does Nginx offer a solution for this? Can nginx handle the 301 itself
without the client ever knowing the redirect happend? Would it be possible
to store the redirect into a client cookie which is read during the next
request and forces nginx to connect to a particular upstream server?

Thank you,

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,254664,254664#msg-254664

More information about the nginx mailing list