Upstream непонятно поведение

BieZax nginx-forum на forum.nginx.org
Чт Ноя 9 10:40:49 UTC 2017


Приветсвую!
Столкнулся  со  странной проблемой:


# nginx  -V
nginx version: nginx/1.12.1
built with OpenSSL 1.0.2l  25 May 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/etc/nginx --with-cc-opt='-I
/usr/local/include' --with-ld-opt='-L /usr/local/lib'
--conf-path=/usr/local/etc/nginx/nginx.conf
--sbin-path=/usr/local/sbin/nginx --pid-path=/var/run/nginx.pid
--error-log-path=/var/log/nginx/error.log --user=www --group=www
--with-cc-opt='-DNGX_HAVE_INET6=0 -I /usr/local/include'
--http-client-body-temp-path=/var/tmp/nginx/client_body_temp
--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi_temp
--http-proxy-temp-path=/var/tmp/nginx/proxy_temp
--http-scgi-temp-path=/var/tmp/nginx/scgi_temp
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi_temp
--http-log-path=/var/log/nginx/access.log --with-http_addition_module
--with-http_auth_request_module
--add-module=/wrkdirs/usr/ports/www/nginx/work/ngx_http_geoip2_module-2.0
--with-http_geoip_module --with-http_gzip_static_module
--with-http_gunzip_module --with-http_realip_module
--with-http_stub_status_module
--add-module=/wrkdirs/usr/ports/www/nginx/work/ngx_devel_kit-0.3.0
--add-module=/wrkdirs/usr/ports/www/nginx/work/lua-nginx-module-0.10.8
--with-pcre --with-http_ssl_module


server {
	listen 80;
	server_name test.example.com;
	error_log /var/log/nginx/test.error_log;
	access_log /var/log/nginx/test.access_log main;

	location / {
		proxy_pass http://test;
		proxy_next_upstream error timeout invalid_header non_idempotent http_500
http_503 http_502 http_504;
	}
}

server {
	listen 127.0.0.1:22001  default_server ;
	error_log /var/log/nginx/test1.error_log;
	return 500;
}

server {
	listen 127.0.0.1:22002  default_server ;
	error_log /var/log/nginx/test2.error_log;

	default_type text/html;
	return 200 "<br> <center><H1> TEST2  </h1></center>";
}

upstream test {
	server 127.0.0.1:22001;
	server 127.0.0.1:22002 backup;
}

Теоретически,   после первого обращения  все  последующие  запросы в течении
  10  секунд  перенаправляются   сразу на  бэкап, и  так оно и  происходит
на тестовом  сервере:
192.168.1.1 - - [08/Nov/2017:18:47:44 +0300] "GET / HTTP/1.0" 200 392 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000, 0.000" "127.0.0.1:22001,
127.0.0.1:22002" "500, 200" "nginx"
192.168.1.1 - - [08/Nov/2017:18:47:44 +0300] "GET / HTTP/1.0" 200 392 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000" "127.0.0.1:22002" "200"
"nginx"
192.168.1.1 - - [08/Nov/2017:18:47:44 +0300] "GET / HTTP/1.0" 200 392 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.001" "0.001" "127.0.0.1:22002" "200"
"nginx"
192.168.1.1 - - [08/Nov/2017:18:47:51 +0300] "GET / HTTP/1.0" 200 392 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000" "127.0.0.1:22002" "200"
"nginx"
192.168.1.1 - - [08/Nov/2017:18:47:51 +0300] "GET / HTTP/1.0" 200 392 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.001" "0.001" "127.0.0.1:22002" "200"
"nginx"
192.168.1.1 - - [08/Nov/2017:18:47:51 +0300] "GET / HTTP/1.0" 200 392 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000" "127.0.0.1:22002" "200"
"nginx"
192.168.1.1 - - [08/Nov/2017:18:47:51 +0300] "GET / HTTP/1.0" 200 392 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000" "127.0.0.1:22002" "200"
"nginx"
192.168.1.1 - - [08/Nov/2017:18:47:55 +0300] "GET / HTTP/1.0" 200 392 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000, 0.000" "127.0.0.1:22001,
127.0.0.1:22002" "500, 200" "nginx"

Но   на  боевом  сервере с  теми же  конфигами  и версией софта картина  
почему-то  меняется:
192.168.1.1 - - [08/Nov/2017:18:50:32 +0300] "GET / HTTP/1.1" 200 397 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000, 0.000" "127.0.0.1:22001,
127.0.0.1:22002" "500, 200" "nginx"
192.168.1.1 - - [08/Nov/2017:18:50:32 +0300] "GET / HTTP/1.1" 200 397 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000, 0.000" "127.0.0.1:22001,
127.0.0.1:22002" "500, 200" "nginx"
192.168.1.1 - - [08/Nov/2017:18:50:33 +0300] "GET / HTTP/1.1" 200 397 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000, 0.000" "127.0.0.1:22001,
127.0.0.1:22002" "500, 200" "nginx"
192.168.1.1 - - [08/Nov/2017:18:50:33 +0300] "GET / HTTP/1.1" 200 397 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000" "127.0.0.1:22002" "200"
"nginx"
192.168.1.1 - - [08/Nov/2017:18:50:34 +0300] "GET / HTTP/1.1" 200 397 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000, 0.000" "127.0.0.1:22001,
127.0.0.1:22002" "500, 200" "nginx"
192.168.1.1 - - [08/Nov/2017:18:50:34 +0300] "GET / HTTP/1.1" 200 397 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000, 0.000" "127.0.0.1:22001,
127.0.0.1:22002" "500, 200" "nginx"
192.168.1.1 - - [08/Nov/2017:18:50:34 +0300] "GET / HTTP/1.1" 200 397 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.001" "0.000, 0.001" "127.0.0.1:22001,
127.0.0.1:22002" "500, 200" "nginx"
192.168.1.1 - - [08/Nov/2017:18:50:35 +0300] "GET / HTTP/1.1" 200 397 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.001" "0.000, 0.001" "127.0.0.1:22001,
127.0.0.1:22002" "500, 200" "nginx"
192.168.1.1 - - [08/Nov/2017:18:50:35 +0300] "GET / HTTP/1.1" 200 397 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000, 0.000" "127.0.0.1:22001,
127.0.0.1:22002" "500, 200" "nginx"
192.168.1.1 - - [08/Nov/2017:18:50:36 +0300] "GET / HTTP/1.1" 200 397 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000" "127.0.0.1:22002" "200"
"nginx"
192.168.1.1 - - [08/Nov/2017:18:50:36 +0300] "GET / HTTP/1.1" 200 397 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000, 0.000" "127.0.0.1:22001,
127.0.0.1:22002" "500, 200" "nginx"
192.168.1.1 - - [08/Nov/2017:18:50:36 +0300] "GET / HTTP/1.1" 200 397 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000, 0.000" "127.0.0.1:22001,
127.0.0.1:22002" "500, 200" "nginx"
192.168.1.1 - - [08/Nov/2017:18:50:37 +0300] "GET / HTTP/1.1" 200 397 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000" "127.0.0.1:22002" "200"
"nginx"
192.168.1.1 - - [08/Nov/2017:18:50:37 +0300] "GET / HTTP/1.1" 200 397 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000, 0.000" "127.0.0.1:22001,
127.0.0.1:22002" "500, 200" "nginx"
192.168.1.1 - - [08/Nov/2017:18:50:38 +0300] "GET / HTTP/1.1" 200 397 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000, 0.000" "127.0.0.1:22001,
127.0.0.1:22002" "500, 200" "nginx"
192.168.1.1 - - [08/Nov/2017:18:50:38 +0300] "GET / HTTP/1.1" 200 397 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.001" "0.000, 0.001" "127.0.0.1:22001,
127.0.0.1:22002" "500, 200" "nginx"
192.168.1.1 - - [08/Nov/2017:18:50:38 +0300] "GET / HTTP/1.1" 200 397 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000, 0.000" "127.0.0.1:22001,
127.0.0.1:22002" "500, 200" "nginx"
192.168.1.1 - - [08/Nov/2017:18:50:39 +0300] "GET / HTTP/1.1" 200 397 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.000" "0.000" "127.0.0.1:22002" "200"
"nginx"
192.168.1.1 - - [08/Nov/2017:18:50:39 +0300] "GET / HTTP/1.1" 200 397 "-"
"curl/7.56.1" "-" "192.168.1.1" "0.001" "0.000, 0.001" "127.0.0.1:22001,
127.0.0.1:22002" "500, 200" "nginx"

Подскажите, почему  может отличатся  поведение на  разных  машинах, если 
софт и  конфиги  идентичны? Разница только в том, что один  нагружен, другой
нет, ну и  в  железе?

Posted at Nginx Forum: https://forum.nginx.org/read.php?21,277219,277219#msg-277219



Подробная информация о списке рассылки nginx-ru