簡體   English   中英

使用 Nginx 負載平衡 opentsdb 客戶端

[英]Load Balancing opentsdb clients using Nginx

我已將 Nginx 配置為對安裝在 centos 中的 opentsdb 客戶端進行負載平衡。 配置如下

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/;
     }
    }
}

當點擊 URL 時,我得到了一個錯誤的網關。 我在這里錯過了什么嗎?

卷曲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>

注意:Nginx 安裝在 10.42.34.12

您應該點擊nginx服務器的IP_Address。 如果10.42.34.12是您的nginx服務器的IP地址。

因此定義它:

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/;

     }
    }
}

我查看了 Nginx 錯誤日志,發現存在權限問題。

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

須藤貓/var/log/audit/audit.log | grep nginx | grep 拒絕

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

設置以下內容並重新啟動 nginx 后,問題就解決了。

setsebool -P httpd_can_network_connect 1

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM