Welcome! Log In Create A New Profile

Advanced

Re: Nginx as LB to redirect/return to upstream server instead of Proxy

Aleksandar Lazic
October 15, 2018 09:16AM
Hi.

Am 15.10.2018 um 09:08 schrieb anish10dec:
> We want to use Nginx as LB in a way so that Nginx can return 301 or 302
> redirect to client instead of Proxying request to backend/upstream servers.
>
> It is required as Server which is configured as LB is having limited
> throughput of 1 Gbps while upstream servers are having throughput of 10Gbps
> .
>
> We want users to directly connect to Upstream Server for Data delivery.
> Nginx LB Server to make sure that all upstream are up and functional before
> giving 301 or 302 redirect to any of upstream server
>
> Example:
>
> http://nginxlb.com/data/download
>
> Nginx LB Returns Redirected URL to Client 301 or 302 ( That upstream should
> be up)
>
> http://upstreamserver1.com/data/download
> http://upstreamserver2.com/data/download
>
> Is this possible by :
>
> return 301 http://$upstream_addr/data/download

I would do this with maps, rewrite and upstream variables.

https://nginx.org/en/docs/http/ngx_http_map_module.html
https://nginx.org/en/docs/http/ngx_http_upstream_module.html#variables
https://nginx.org/en/docs/http/ngx_http_rewrite_module.html

Untested:
###
map $upstream_addr $direct_domain {
default nginxlb.com;
IP1 upstreamserver1.com;
IP2 upstreamserver2.com;
}

return 301 http://$direct_domain/data/download
###

Regards
Aleks

> Posted at Nginx Forum: https://forum.nginx.org/read.php?2,281590,281590#msg-281590
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>

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

Nginx as LB to redirect/return to upstream server instead of Proxy

anish10dec October 15, 2018 03:08AM

Re: Nginx as LB to redirect/return to upstream server instead of Proxy

Aleksandar Lazic October 15, 2018 09:16AM

Re: Nginx as LB to redirect/return to upstream server instead of Proxy

Maxim Dounin October 15, 2018 10:46AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 49
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready