在http内新增如下代码
//要被转发到的地址
upstream mqttservice{
server ip1:18083 weight=1;
server ip2:18083 weight=1;
server ip3:18083 weight=1;
}
server {
listen 9816;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://mqttservice;
}
}