如何使用 nginx 从端口获取数据并将其转发到其他 syslog-ng 服务器?

如何使用 nginx 从端口获取数据并将其转发到其他 syslog-ng 服务器?

我正在将数据发送到 nginx 服务器上的 9516 端口。我想使用 roundrobin 方法从此服务器将其转发到两个 syslog-ng 服务器。我有以下 nginx.conf 文件,通过它我能够平衡我的 kibana 网页的负载,但我不确定在哪里以及如何读取 9516 端口,然后将其转发到 syslog-ng 机器。

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
        worker_connections 768;
}

http {
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        include /etc/nginx/mime.types;
        default_type application/octet-stream;
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;
        gzip on;
        gzip_disable "msie6";
        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
upstream kibana {
    server1:30001;
    server2:30001;
  }

  server { # simple load balancing
    listen          80;
    server_name     nginxIP;
   # SSL Certificate, Key and Settings
        ssl_certificate /etc/pki/tls/certs/ELK-Stack.crt ;
        ssl_certificate_key /etc/pki/tls/private/ELK-Stack.key;
        ssl_session_cache shared:SSL:10m;

        # Basic authentication using the account created with htpasswd
        auth_basic "Restricted Access";
        auth_basic_user_file /etc/nginx/htpasswd.users;
    location / {
      proxy_pass      http://kibana;
    }
}

我寻求了上面的帮助,并尝试添加下面的内容,但出现了错误

upstream syslog-ng {
    syslog-ng-server1:9516;
    syslog-ng-server2:9516;
  }

  server { # simple load balancing
    listen          9516;
    server_name     nginxIP;
    location / {
      proxy_pass      http://syslog-ng;
    }
}

使用 netcat 命令向 9516 端口发送日志时出错

<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx/1.4.6 (Ubuntu)</center>
</body>
</html>

请帮忙。

问候 VG

相关内容