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;
        }
    }
相关推荐
ping某12 小时前
为什么 Nginx 明明监听了 80,转发后端时却用了 4xxxx 端口?
后端·nginx
霜落长河2 天前
抛弃TCP改用UDP,HTTP3怎么了?
http
之歆3 天前
现代 HTTP 客户端深度解析:Fetch 与 Axios
chrome·网络协议·http
難釋懷3 天前
Nginx反向代理中的容错机制
运维·nginx
bloglin999993 天前
Nginx高危漏洞CVE-2021-23017及配置样例
运维·nginx
进阶的小名3 天前
Spring Boot SSE + Nginx 配置:解决 EventSource 不实时返回、连接超时、流式响应被缓冲问题
spring boot·后端·nginx
難釋懷3 天前
Nginx获取客户端真实IP
服务器·前端·nginx
qq_谁赞成_谁反对3 天前
甲方IT的成长之路--nginx实战--2604
服务器·数据库·nginx
程序员mine3 天前
HTTPS-TLS加密与证书完全指南(下)
网络协议·http·https
图灵追慕者3 天前
Nginx安裝以及配置顯示本地服務器文件夾
运维·nginx