Welcome! Log In Create A New Profile

Advanced

Re: Handling redirects among upstream servers

Maxim Dounin
November 07, 2014 09:04AM
Hello!

On Fri, Nov 07, 2014 at 05:11:44AM -0500, zappa wrote:

> Hello,
>
> 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?

In no particular order:

- You can avoid changes to the Location header, or control them as
needed. The flexibility provied by the proxy_redirect directive
should be enough to preserve information needed. See
http://nginx.org/r/proxy_redirect for details.

- You can instruct nginx to forward requests to another node
by itself, using the X-Accel-Redirect header. This may be a
good solution if you are willing to rewrite application servers to
use features provided by nginx.

- Redirections can be intercepted using the error_page and
proxy_intercept_errors directives (I wouldn't recommend this
though).

--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Handling redirects among upstream servers

zappa November 07, 2014 05:11AM

Re: Handling redirects among upstream servers

Maxim Dounin November 07, 2014 09:04AM

Re: Handling redirects among upstream servers

zappa November 07, 2014 12:25PM

Re: Handling redirects among upstream servers

zappa November 07, 2014 02:05PM

Re: Handling redirects among upstream servers

Maxim Dounin November 10, 2014 07:32AM

Re: Handling redirects among upstream servers

B.R. November 10, 2014 01:16PM

Re: Handling redirects among upstream servers

zappa November 11, 2014 03:40AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 290
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready