elasticsearch,kibana,Nginx,elasticsearch,Kibana" /> elasticsearch,kibana,Nginx,elasticsearch,Kibana" />

Nginx Elasticsearch:连接到上游时拒绝连接

Nginx Elasticsearch:连接到上游时拒绝连接,nginx,elasticsearch,kibana,Nginx,elasticsearch,Kibana,我已经用Kibana设置了一个Elasticsearch服务器来收集一些日志 Elasticsearch位于Nginx的反向代理之后,以下是配置: server { listen 8080; server_name myserver.com; error_log /var/log/nginx/elasticsearch.proxy.error.log; access_log off; location / { # Deny Nodes Sh

我已经用Kibana设置了一个Elasticsearch服务器来收集一些日志

Elasticsearch位于Nginx的反向代理之后,以下是配置:

server {   
  listen   8080;   
  server_name myserver.com; 
  error_log   /var/log/nginx/elasticsearch.proxy.error.log;
  access_log  off;

  location / {

    # Deny Nodes Shutdown API
    if ($request_filename ~ "_shutdown") {
      return 403;
      break;
    }

    # Pass requests to ElasticSearch
    proxy_pass http://localhost:9200;
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Connection "";

    proxy_set_header  X-Real-IP  $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header  Host $http_host;

    # For CORS Ajax
    proxy_pass_header Access-Control-Allow-Origin;
    proxy_pass_header Access-Control-Allow-Methods;
    proxy_hide_header Access-Control-Allow-Headers;
    add_header Access-Control-Allow-Headers 'X-Requested-With, Content-Type';
    add_header Access-Control-Allow-Credentials true;

  }

}
一切都很好,我可以
curl-XGET“myserver.com:8080”
进行检查,然后我的日志就进来了

但每隔一分钟左右,在nginx错误日志中,我都会发现:

2014/05/28 12:55:45 [error] 27007#0: *396 connect() failed (111: Connection refused) while connecting to upstream, client: [REDACTED_IP], server: myserver.com, request: "POST /_bulk?replication=sync HTTP/1.1", upstream: "http://[::1]:9200/_bulk?replication=sync", host: "myserver.com"

我搞不清楚它是什么,conf中是否有任何问题会阻止一些批量请求通过

看起来像是
上游
,ES后端需要另一个
keepalive
才能正常工作,我最终使用以下配置使其工作:

upstream elasticsearch {
    server 127.0.0.1:9200;
    keepalive 64;
}

server {

  listen 8080;
  server_name myserver.com;
  error_log   /var/log/nginx/elasticsearch.proxy.error.log;
  access_log  off;

  location / {

    # Deny Nodes Shutdown API
    if ($request_filename ~ "_shutdown") {
      return 403;
      break;
    }

    # Pass requests to ElasticSearch
    proxy_pass http://elasticsearch;
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Connection "";

    proxy_set_header  X-Real-IP  $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header  Host $http_host;

    # For CORS Ajax
    proxy_pass_header Access-Control-Allow-Origin;
    proxy_pass_header Access-Control-Allow-Methods;
    proxy_hide_header Access-Control-Allow-Headers;
    add_header Access-Control-Allow-Headers 'X-Requested-With, Content-Type';
    add_header Access-Control-Allow-Credentials true;

  }

}