Welcome! Log In Create A New Profile

Advanced

how to make nginx loadbalancer give 404 when all upstream servers are down

August 13, 2015 05:12AM
Hi folks,

I have been stuck this issue for a long time now. Searches could not solve my issue hence posting here.
Please help.

I am using nginx as a load balancer and ngnix.conf looks like:

worker_processes 4;

events { worker_connections 1024; }

http {
upstream ab_backend {
server <IP1>:7000;
server <IP2>:7000 backup;
}

server {
listen 8000;

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://ab_backend;
}
}
}
IP1 and IP2 are simple httpd docker containers. From another machine I am running ab tool. What I am observing is: When IP1 is up the http it responds to request from ab. Bring IP1 and backup IP2 starts to respond to al http requests.

starnge thing is when both IP1, IP2 are down the nginx server itself takes it up and responds to the http requests from ab. Is there a way to make nginx not behave this way?

what I am looking for is way to force http requests to be answered by only the upstream servers if none of them are reachable requests should get errors instead of giving out non bona fide responses.

I am testing using ab and httperf tool and saw the bahavior in both cases. Even when no upstreams are up test reports no Errors or dropped requests. Please help :)
Subject Author Posted

how to make nginx loadbalancer give 404 when all upstream servers are down

karkunpavan August 13, 2015 05:12AM

Re: how to make nginx loadbalancer give 404 when all upstream servers are down

Francis Daly August 13, 2015 07:14AM

Re: how to make nginx loadbalancer give 404 when all upstream servers are down

karkunpavan August 14, 2015 02:06AM

Re: how to make nginx loadbalancer give 404 when all upstream servers are down

itpp2012 August 14, 2015 03:12AM

Re: how to make nginx loadbalancer give 404 when all upstream servers are down

karkunpavan August 14, 2015 03:45AM

Re: how to make nginx loadbalancer give 404 when all upstream servers are down

Francis Daly August 14, 2015 03:56AM

Re: how to make nginx loadbalancer give 404 when all upstream servers are down

karkunpavan August 14, 2015 04:17AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 148
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