nginx配置http负载均衡转发

在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;
        }
    }
相关推荐
sonadorje12 分钟前
HTTP Cookie解析
网络·网络协议·http
w***153115 分钟前
四、nginx的优化和location匹配规则
运维·nginx
我不是张鸭鸭19 分钟前
nginx的https的搭建
运维·nginx·https
007php00732 分钟前
nginx加速缓存导致Event-Stream消息延迟问题的解决方案
运维·网络·数据库·nginx·缓存·面试·职场和发展
O***Z61638 分钟前
httpslocalhostindex 配置的nginx,一刷新就报404了
运维·nginx
e***28291 小时前
报错The default superclass, “jakarta.servlet.http.HttpServlet“(已经配置好tomcat)
http·servlet·tomcat
f***24111 小时前
不常用,总是忘记:nginx 重启指令
运维·windows·nginx
007php0072 小时前
nginx面试之负载均衡的实际经历与配置
运维·数据库·mysql·nginx·面试·职场和发展·负载均衡
6***v4172 小时前
启动nginx报错nginx [emerg] bind() to 0.0.0.080 failed (98 Address already in use)
运维·nginx
濊繵2 小时前
Linux网络--应用层协议 HTTP
网络·网络协议·http