Opposite behavior of keepalive (nginx reverse proxy on ElasticSearch)
dr01
nginx-forum at forum.nginx.org
Mon Feb 22 08:52:42 UTC 2016
I am setting up a nginx reverse proxy for ElasticSearch (with HTTP Basic
Auth) as described in this article:
https://www.elastic.co/blog/playing-http-tricks-nginx
This is my nginx config file:
events {
worker_connections 1024;
}
http {
upstream elasticsearch {
server elasticsearch.example.org:9200;
keepalive 64;
}
server {
listen 8080;
location / {
auth_basic "ElasticSearch";
auth_basic_user_file /var/www/.htpasswd;
proxy_pass http://elasticsearch.example.org:9200;
proxy_http_version 1.1;
proxy_set_header Connection "Keep-Alive";
proxy_set_header Proxy-Connection "Keep-Alive";
}
}
}
The proxy correctly forwards port 8080 to 9200, and is supposed to keep
persistent connections (keepalive) to Elasticsearch.
This is the result of visiting either the URL
http://elasticsearch.example.org:9200/_nodes/stats/http?pretty or
http://elasticsearch.example.org:8080/_nodes/stats/http?pretty (HTTP
authentication has already been done) in a browser:
{
"cluster_name" : "elasticsearch",
"nodes" : {
"rIFmzNwsRvGp8kipbcwajw" : {
"timestamp" : 1455899085319,
"name" : "Kid Colt",
"transport_address" : "elasticsearch.example.org/10.3.3.3:9300",
"host" : "10.3.3.3",
"ip" : [ "elasticsearch.example.org/10.3.3.3:9300", "NONE" ],
"http" : {
"current_open" : 3,
"total_opened" : 28
}
}
}
}
When visiting the page on port 9200 (direct connection to Elasticsearch) and
reloading, the field total_opened is supposed to increase, while when
visiting on port 8080 (through the nginx proxy) and reloading, the field
should not change.
In fact, it happens the opposite. What is the reason of this strange
behavior?
Posted at Nginx Forum: https://forum.nginx.org/read.php?2,264702,264702#msg-264702
More information about the nginx
mailing list