# Nginx-Upstream-proxy next upstream-惊天大Bug

**URL:** <https://www.ruby-forum.com/t/nginx-upstream-proxy-next-upstream-bug/220173>\
**Category:** NGINX\
**Created:** [May 31, 2012, 4:55pm UTC](https://www.ruby-forum.com/t/nginx-upstream-proxy-next-upstream-bug/220173 "2012-05-31T16:55:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gurdipe\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b77776/32.png) [@Gurdipe\_D](https://www.ruby-forum.com/u/Gurdipe_D)\
**Post date:** [May 31, 2012, 4:55pm UTC](https://www.ruby-forum.com/t/nginx-upstream-proxy-next-upstream-bug/220173/1 "2012-05-31T16:55:40Z")

</div>

upstream backend {  
server [flvdownload.ppserver.org.cn:80](http://flvdownload.ppserver.org.cn:80) max\_fails=0;  
server [flvstorage.ppserver.org.cn:80](http://flvstorage.ppserver.org.cn:80) backup;  
}

server{  
…  
location / {  
proxy\_next\_upstream error timeout invalid\_header http\_500 http\_502  
http\_503 http\_504;  
proxy\_pass [http://backend](http://backend);  
}  
}

#----------------------------------------------------------------------------------------

当upstream中backup域名“  
[flvstorage.ppserver.org.cn](http://flvstorage.ppserver.org.cn)”解析结果为2个IP时候，“[flvdownload.ppserver.org.cn](http://flvdownload.ppserver.org.cn)”如果返回有异常可以成功proxy\_pass到backup。  
But：当upstream中backup域名“  
[flvstorage.ppserver.org.cn](http://flvstorage.ppserver.org.cn)”解析结果为1个IP时候，backup无法使用，nginx会不断的请求“[flvdownload.ppserver.org.cn](http://flvdownload.ppserver.org.cn)”。

屡试不爽，就是不知道这是一个Bug吗？

Posted at Nginx Forum:

> **[Nginx-Upstream-proxy\_next\_upstream-惊天大Bug](https://forum.nginx.org/read.php?2,227074,227074#msg-227074)**
>
> upstream backend { server flvdownload.ppserver.org.cn:80 max\_fails=0; server flvstorage.ppserver.org.cn:80 backup; } server{ .... location / { proxy\_next\_upstream error timeout invalid\_header http\_500 http\_502 http\_503 http\_5

---

<div class="post-metadata">

**Author:** ![youzhengchuan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/50afbb/32.png) [@youzhengchuan](https://www.ruby-forum.com/u/youzhengchuan)\
**Post date:** [May 31, 2012, 5:13pm UTC](https://www.ruby-forum.com/t/nginx-upstream-proxy-next-upstream-bug/220173/2 "2012-05-31T17:13:03Z")

</div>

Hello!

On Thu, May 31, 2012 at 10:55:11AM -0400, youzhengchuan wrote:

> ```
> proxy_pass http://backend;
> 
> ```
> 
> 屡试不爽，就是不知道这是一个Bug吗？  
> As far as I understand, you are hitting another variant of this bug:

> **[\#47 (loop with backup servers and proxy\_next\_upstream http\_404)
          –...](https://trac.nginx.org/nginx/ticket/47)**

It usually manifests itself with “proxy\_next\_upstream http\_404”,  
but max\_fails=0 does essentially the same. The bug is fixed in  
1.3.0.

Maxim D.

p.s. This is English mailing list, please don’t write in Chinese  
here. Thank you.

---

<div class="post-metadata">

**Author:** ![youzhengchuan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/50afbb/32.png) [@youzhengchuan](https://www.ruby-forum.com/u/youzhengchuan)\
**Post date:** [June 1, 2012, 1:44pm UTC](https://www.ruby-forum.com/t/nginx-upstream-proxy-next-upstream-bug/220173/3 "2012-06-01T13:44:24Z")

</div>

Do something like this:

you need to define a resolver:

resolver 8.8.8.8; # or your dns serevrs

location / {  
set $myupstream [flvdownload.ppserver.org.cn](http://flvdownload.ppserver.org.cn);  
proxy\_pass http://$myupstream;  
}

if you need it to use multiple ip addresses.

---

<div class="post-metadata">

**Author:** ![youzhengchuan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/50afbb/32.png) [@youzhengchuan](https://www.ruby-forum.com/u/youzhengchuan)\
**Post date:** [June 1, 2012, 9:59am UTC](https://www.ruby-forum.com/t/nginx-upstream-proxy-next-upstream-bug/220173/4 "2012-06-01T09:59:52Z")

</div>

Accordance with the above configuration, When the domain  
“[flvstorage.ppserver.org.cn](http://flvstorage.ppserver.org.cn),” nginx nslookup results is just a one IP  
address, this backend upstream can’t be used.

my apology for my bad english.

Posted at Nginx Forum:

> **[Re: Nginx-Upstream-proxy next upstream-惊天大Bug](https://forum.nginx.org/read.php?2,227075,227089#msg-227089)**
>
> Hello! On Thu, May 31, 2012 at 10:55:11AM -0400, youzhengchuan wrote: \> upstream backend { \> server flvdownload.ppserver.org.cn:80 max\_fails=0; \> server flvstorage.ppserver.org.cn:80 backup; \> } \> \> server{ &g

---

<div class="post-metadata">

**Author:** ![youzhengchuan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/50afbb/32.png) [@youzhengchuan](https://www.ruby-forum.com/u/youzhengchuan)\
**Post date:** [June 4, 2012, 10:19am UTC](https://www.ruby-forum.com/t/nginx-upstream-proxy-next-upstream-bug/220173/5 "2012-06-04T10:19:02Z")

</div>

thanks Brian

Posted at Nginx Forum:

> **[Re: Nginx-Upstream-proxy next upstream-惊天大Bug](https://forum.nginx.org/read.php?2,227075,227139#msg-227139)**
>
> Hello! On Thu, May 31, 2012 at 10:55:11AM -0400, youzhengchuan wrote: \> upstream backend { \> server flvdownload.ppserver.org.cn:80 max\_fails=0; \> server flvstorage.ppserver.org.cn:80 backup; \> } \> \> server{ &g
