﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	uname	nginx_version
666	Nginx retry the failed http request not only from the servers defined inside the associated upstream, but also the upstream's name as well	Ryan Chan		"Please read the attached nginx.conf file.

This is what I want to achieve:
- Nginx as a reverse proxy and load balancer
- Redirect traffic to either 127.0.0.1:4001 or 127.0.0.1:4002, using round robin scheme
- In the attached nginx config, I have defined a upstream group called ""RESTfulFromLive"", with server 127.0.0.1:4001 and 127.0.0.1:4002.

Expected behavior:
- Scenario A: Both 127.0.0.1:4001 and 127.0.0.1:4002 are online
  - Requests are round robin to 127.0.0.1:4001 and 127.0.0.1:4002 correctly
  - Each requests returned 200.
- Scenario B: Both 127.0.0.1:4001 and 127.0.0.1:4002 are offline
  - Requests are round robin to 127.0.0.1:4001 and 127.0.0.1:4002 correctly
  - Each requests returned 502.

Actual behavior:
- Scenario A:
  - Work as expected/
- Scenario B:
  - Basically there are two types of proxied requests:
    - 10.50.100.238 - [19/Nov/2014:18:48:39 +0800] ""GET /Content/a.txt HTTP/1.1"" 502 537 ""-"" ""-"" 0.001 127.0.0.1:4002, 127.0.0.1:4001 - 502, 502 ""-"" 0.000, 0.001
    - 10.50.100.238 - [19/Nov/2014:18:48:39 +0800] ""GET /Content/a.txt HTTP/1.1"" 502 537 ""-"" ""-"" 0.000 RESTfulFromLive - 502 ""-"" 0.000
  - First type of request is expected, Nginx retried the failed requests to the other servers defined in the upstream.
  - Second type of request is NOT expected, as RESTfulFromLive request is an upstream name, the request must be failed.

I have tried many different nginx configuration, and in general, this bug will be hit if nginx is configured to retry the failed proxied request (e.g. proxy_next_upstream is configured.), and all upstream servers returned error code. That's why I propose this is a blocker issue.


{{{
#worker_processes  auto;
pid  /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    # include  mime.types;
    default_type  application/octet-stream;

    sendfile  on;

    keepalive_timeout  65;

    upstream RESTfulFromLive {
        server 127.0.0.1:4001;
        server 127.0.0.1:4002;
    }

    log_format  timed_combined '$remote_addr $remote_user [$time_local] ""$request"" $status $body_bytes_sent ""$http_referer"" ""$http_header"" $request_time $upstream_addr $upstream_cache_status $upstream_status ""$upstream_http_header"" $upstream_response_time';

    access_log  /mnt/sda7/nmi/log/nginx-access.log timed_combined;
    error_log   /mnt/sda7/nmi/log/nginx-error.log warn;

    server {
        listen  80;
        server_name  localhost;

        location / {
            proxy_pass http://RESTfulFromLive;
            # proxy_next_upstream error timeout invalid_header http_403 http_500 http_502 http_503 http_504;
        }

        # redirect server error pages to the static page /50x.html
        #
        error_page  500 502 503 504  /50x.html;
        location = /50x.html {
            root  html;
        }
    }
}

}}}


Ryan Chan"	defect	closed	blocker		nginx-core	1.7.x	invalid	upstream			"nginx version: nginx/1.7.7
built by gcc 4.6.3 (GCC)
TLS SNI support enabled
configure arguments: --with-http_ssl_module --with-http_stub_status_module --with-ipv6 --with-pcre=./pcre-8.34 --without-http_fastcgi_module --without-http_scgi_module --with-http_auth_request_module"
