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;
        }
    }
相关推荐
ん贤5 分钟前
nginx语法
nginx
萧曵 丶3 小时前
Nginx 高频面试题(含答案)
运维·nginx
无名的小白4 小时前
openclaw使用nginx反代部署过程 与disconnected (1008): pairing required解决
java·前端·nginx
wengad4 小时前
podman搭建nginx服务
运维·nginx·podman
regret~7 小时前
【笔记】Nginx 核心操作 + 配置解析笔记(适配 Linux+FastAPI / 前端代理场景)
linux·笔记·nginx
软件资深者8 小时前
免费的2026网刻工具, 轻松解决局域网电脑批量还原问题
运维·服务器·负载均衡
cyber_两只龙宝8 小时前
haproxy--使用socat工具实现对haproxy权重配置的热更新
linux·运维·负载均衡·haproxy·socat
csdn2015_9 小时前
Spring Boot `HttpServletRequest`
spring boot·http·servlet
萧曵 丶9 小时前
Nginx常用配置
运维·nginx
有代理ip9 小时前
后端服务安全加固:Nginx 反向代理配置教程
运维·nginx·安全