Welcome! Log In Create A New Profile

Advanced

Opposite behavior of keepalive (nginx reverse proxy on ElasticSearch)

February 22, 2016 03:52AM
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?
Subject Author Posted

Opposite behavior of keepalive (nginx reverse proxy on ElasticSearch)

dr01 February 22, 2016 03:52AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 258
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready