当前位置:网站首页>Using domain name forwarding mqtt protocol, pit avoidance Guide
Using domain name forwarding mqtt protocol, pit avoidance Guide
2022-06-27 05:19:00 【Ape fly】
1. demand
We need to do it by domain name mqtt Link to . The advantage is that when we are backstage ip When things change , The front-end equipment can not be affected .
2. Use nginx Forward
Pay attention to problems : Configure reverse proxy TCP The way , Need to use nginx Of stream Service node . The node is and http Nodes are juxtaposed .
The use of nginx Version of :1.23.0

Version problem , This is because some older versions require manual installation support stream. So if we use a higher version , These are supported by default .
2.1.nginx Configuration file in

We are directly in the nginx.conf Internal configuration , Because of the need to sum http Same node .
The complete configuration file is also posted :
stream {
log_format proxy '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time "$upstream_addr" '
'"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';
access_log /var/log/nginx/mqtt_access.log proxy;
open_log_file_cache off;
upstream mqtt_tcp_server {
server xxx.xxx.xxx.xxx:1883; # Here we need to change our own ip Address
}
server {
listen 1883; # Listening port You can also use 1883
proxy_connect_timeout 150s;
proxy_timeout 150s;
proxy_pass mqtt_tcp_server; # Reverse proxy address
proxy_buffer_size 3M;
tcp_nodelay on;
}
}
3. After configuration , restart nginx Don't take effect
netstat -tunpl
Use this command , You can see that we are listening 1883 Whether the port is up . At the beginning of the abnormality , Because use nginx -t, There is no problem with grammar , In the use of nginx -s reload When the command starts . There are no abnormalities , But it turns out 1883 The port is still not up . Let's go check nginx Of error journal , Finally, an error was found .
2022/06/24 14:48:40 [emerg] 11768#11768: bind() to 0.0.0.0:1883 failed (13: Permission denied)3.1. This problem , It's actually SELinux Open and close ports problem ;
View all open ports :
semanage port -lLook at a port :
see 1883 Whether the port has been opened :
semanage port -l | grep 1883
The results after the startup .
see selinux in the light of http The policy of opening ports :
semanage port -l | grep http_port_t Add port :
The key is coming. , If the above result is not open , You need to add ports manually :
semanage port -a -t http_port_t -p tcp 1883http Policy add open 1883 port .
close http A port of the policy :
Last , If at some time , When we don't need to open this port , You can close the port :
semanage port -d -t http_port_t -p tcp 1883边栏推荐
- 022 basics of C language: C memory management and C command line parameters
- 导航【机器学习】
- leetcode298周赛记录
- Execution rules of pytest framework
- 016 C language foundation: C language enumeration type
- 双位置继电器JDP-1440/DC110V
- LeetCode-515. 在每个树行中找最大值
- Neo4j database export
- C语言实现定时器
- Niuke practice 101-c reasoning clown - bit operation + thinking
猜你喜欢

Niuke practice 101-c reasoning clown - bit operation + thinking

体验 win10 下 oceanbase 数据库

What is BFC? What's the usage?

Deep dive kotlin synergy (XV): Test kotlin synergy

jq怎么获取元素的id名

Penetration test - file upload / download / include

stm32读取IO高低电平状态

Asp. Net core6 websocket simple case

竣达技术丨多品牌精密空调集中监控方案

快速排序(非遞歸)和歸並排序
随机推荐
洛谷P2939 [USACO09FEB]Revamping Trails G 题解
流媒体协议初探(MPEG2-TS、RTSP、RTP、RTCP、SDP、RTMP、HLS、HDS、HSS、MPEG-DASH)
018 basics of C language: C file reading and writing
Mechanical transcoding journal [17] template, STL introduction
论文解读(LG2AR)《Learning Graph Augmentations to Learn Graph Representations》
Edge在IE模式下加载网页 - Edge设置IE兼容性
Interview: what are the positioning methods in selenium? Which one do you use most?
golang hello 安装环境异常【已解决】
STM32 reads IO high and low level status
Unity point light disappears
微信小程序刷新当前页面
When STM32 turns off PWM output, it is a method to fix IO output at high or low level.
竣达技术丨多品牌精密空调集中监控方案
neo4j community与neo4j desktop冲突
py2neo基本语法
017 basics of C language: bit field and typedef
Experience oceanbase database under win10
Neo4j database export
Remapping (STM32)
How JQ gets the reciprocal elements