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

Aleksandar Lazic al-nginx at none.at
Mon Oct 15 13:15:39 UTC 2018


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 at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
> 



More information about the nginx mailing list