# Strange upstream behaviour

**URL:** <https://www.ruby-forum.com/t/strange-upstream-behaviour/244016>\
**Category:** NGINX\
**Created:** [February 5, 2016, 12:27pm UTC](https://www.ruby-forum.com/t/strange-upstream-behaviour/244016 "2016-02-05T12:27:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [February 5, 2016, 12:27pm UTC](https://www.ruby-forum.com/t/strange-upstream-behaviour/244016/1 "2016-02-05T12:27:21Z")

</div>

Hello,

We are using nginx as a loadbalancer in front of docker containers. Most  
of  
the time this works without problems. But sometimes (~0.1% of the  
requests)  
the requests are sent to the server group name instead of one of the  
members  
of the servergroup.

upstream gateway {  
server 127.0.0.1:6000 weight=1000000;  
server 1.2.3.4:6000;  
}

server {  
listen :443;  
ssl on;  
server\_name ;

```
<ssl config>

location / {
   proxy_pass http://gateway;
}

```

}

Most of the time the requests are logged as expected:

03/Feb/2016:04:00:25 +0100 “/api/v1/login” 200 52 “Jersey/2.7  
(HttpUrlConnection 1.8.0\_51)” “time=0.192” “”  
“upstream=127.0.0.1:6000”  
or  
03/Feb/2016:04:00:25 +0100 “/api/v1/login” 200 52 “Jersey/2.7  
(HttpUrlConnection 1.8.0\_51)” “time=0.192” “”  
“upstream=1.2.3.4:6000”

But randomly this happens:

03/Feb/2016:04:00:25 +0100 “/api/v1/login” 502 52 “Jersey/2.7  
(HttpUrlConnection 1.8.0\_51)” “time=0.192” “”  
“upstream=gateway”

As you can see, it uses the server group name as the upstream target  
(which  
fails of course since this is not a valid host).

What could be the cause of this behaviour?

All the best,  
Armin

Posted at Nginx Forum:

> **[Strange upstream behaviour](https://forum.nginx.org/read.php?2,264368,264368#msg-264368)**
>
> Hello, We are using nginx as a loadbalancer in front of docker containers. Most of the time this works without problems. But sometimes (~0.1% of the requests) the requests are sent to the server group name instead of one of the members of the...

---

<div class="post-metadata">

**Author:** ![abauer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/cab0a1/32.png) [@abauer](https://www.ruby-forum.com/u/abauer)\
**Post date:** [February 5, 2016, 2:34pm UTC](https://www.ruby-forum.com/t/strange-upstream-behaviour/244016/2 "2016-02-05T14:34:02Z")

</div>

Hello!

On Fri, Feb 05, 2016 at 06:26:28AM -0500, abauer wrote:

> We are using nginx as a loadbalancer in front of docker containers. Most of  
> the time this works without problems. But sometimes (~0.1% of the requests)  
> the requests are sent to the server group name instead of one of the members  
> of the servergroup.

[…]

> But randomly this happens:
> 
> 03/Feb/2016:04:00:25 +0100 “/api/v1/login” 502 52 “Jersey/2.7  
> (HttpUrlConnection 1.8.0\_51)” “time=0.192” “”  
> “upstream=gateway”
> 
> As you can see, it uses the server group name as the upstream target (which  
> fails of course since this is not a valid host).
> 
> What could be the cause of this behaviour?

Upstream name can be seen in the $upstream\_addr variable if nginx  
wasn’t able to select an upstream server to connect to because all  
servers were down as per max\_fails/fail\_timeout. At the same time  
the “no live upstreams” error is logged to the error log.

–  
Maxim D.

> **[nginx](http://nginx.org/)**

---

<div class="post-metadata">

**Author:** ![abauer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/cab0a1/32.png) [@abauer](https://www.ruby-forum.com/u/abauer)\
**Post date:** [February 5, 2016, 4:01pm UTC](https://www.ruby-forum.com/t/strange-upstream-behaviour/244016/3 "2016-02-05T16:01:39Z")

</div>

Thank you, that would explain the message. Ill check why the upstream  
servers might not have been reachable.

All the best,  
Armin

Posted at Nginx Forum:

> **[Re: Strange upstream behaviour](https://forum.nginx.org/read.php?2,264368,264381#msg-264381)**
>
> Hello, We are using nginx as a loadbalancer in front of docker containers. Most of the time this works without problems. But sometimes (~0.1% of the requests) the requests are sent to the server group name instead of one of the members of the...
