简体   繁体   English

使用 Nginx 负载平衡 opentsdb 客户端

[英]Load Balancing opentsdb clients using Nginx

I have configured Nginx to load balance opentsdb clients installed in centos.我已将 Nginx 配置为对安装在 centos 中的 opentsdb 客户端进行负载平衡。 The configuration looks like below配置如下

events {}

http {
    upstream opentsdblb {
      least_conn;
      server 10.42.34.11:4242;
      server 10.42.34.12:4242;
    }

    server {
     listen 80;

     location / {
      proxy_pass http://opentsdblb/;
     }
    }
}

When hitting the URL I am getting a bad gateway.当点击 URL 时,我得到了一个错误的网关。 Am I missing something here?我在这里错过了什么吗?

curl http://10.42.34.12卷曲http://10.42.34.12

<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.16.1</center>
</body>
</html>

Note: Nginx is installed in 10.42.34.12注意:Nginx 安装在 10.42.34.12

You should hit IP_Address of nginx server. 您应该点击nginx服务器的IP_Address。 if 10.42.34.12 is IP address of your nginx server. 如果10.42.34.12是您的nginx服务器的IP地址。

So define it: 因此定义它:

events {}

http {
    upstream opentsdblb {
      least_conn;
      server 10.42.34.11:4242;
      server 10.42.34.12:4242;
    }

    server {
     listen 80;

     server_name  10.42.34.12; 

     location / {

      proxy_pass http://opentsdblb/;

     }
    }
}

I checked the Nginx error logs and found that there is a permission issue.我查看了 Nginx 错误日志,发现存在权限问题。

*1 connect() to 10.42.34.11:4242 failed (13: Permission denied) while connecting to upstream

sudo cat /var/log/audit/audit.log |须藤猫/var/log/audit/audit.log | grep nginx | grep nginx | grep denied grep 拒绝

type=AVC msg=audit(1574848605.888:133226): avc:  denied  { name_connect } for  
The issue is resolved by setting the 

After setting the below and restarting nginx the issue is resolved.设置以下内容并重新启动 nginx 后,问题就解决了。

setsebool -P httpd_can_network_connect 1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM