参考: https://blog.csdn.net/yinjl123/article/details/132610040
1.nginx安装编译时,需要增加--with-stream
模块
wget https://nginx.org/download/nginx-1.22.1.tar.gz
tar -zxvf nginx-1.22.1.tar.gz
cd nginx-1.22.1
./configure --with-stream
make
make install
- 修改nginx配置文件
cd /usr/local/nginx/conf
vim nginx.conf
在http同级,添加stream模块
stream {
upstream mqtt_server {
server 192.168.33.15:1883;
}
server {
listen 8086 so_keepalive=on;
proxy_pass mqtt_server;
}
}
http {
}
3.启动nginx
cd /usr/local/nginx/
cd sbin
./nginx