upstream redirect instead proxy_pass

Maxim Dounin mdounin at mdounin.ru
Mon May 18 15:03:52 UTC 2015


Hello!

On Sun, May 17, 2015 at 01:07:30PM -0400, EvilMoe wrote:

> Hello,
> 
> I would like to use Nginx as Load Balancer (traffic). My config is:
> 
> 
> upstream storages {
>         least_conn;
>         server str1 weight=1 max_fails=1 fail_timeout=10s;
>         server str2 weight=1 max_fails=1 fail_timeout=10s;
> }
> 
> 
> server {
>         listen 80;
>         server_name verteilen;
>         location / {
>                 proxy_pass http://storages;
>                 #return 302 $scheme://storages;
>         }
> }
> 
> 
> 
> 
> How can I redirect to the server of upstream? With proxy_pass does it work
> but I want to move the traffic to several servers.
> I just need the "storages" variable.

The "upstream" directives defines servers for proxy - and things 
like "least_conn" balancer in your config are not at all possible 
unless nginx proxies connections.

If you want nginx to return redirects, you can use other 
mechanisms available, like split_clients:

http://nginx.org/en/docs/http/ngx_http_split_clients_module.html

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



More information about the nginx mailing list