Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
I
iot-mqtt-bl
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
deploy
iot-mqtt-bl
Commits
7201ca24
Commit
7201ca24
authored
Nov 28, 2023
by
吴文龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
up 定时切换配置文件
parent
2c3ca21c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
153 additions
and
1 deletion
+153
-1
README.md
README.md
+9
-1
current_config.txt
haproxy/config/current_config.txt
+1
-0
haproxy_config1.cfg
haproxy/config/haproxy_config1.cfg
+64
-0
haproxy_config2.cfg
haproxy/config/haproxy_config2.cfg
+64
-0
rotate_haproxy_config.sh
rotate_haproxy_config.sh
+15
-0
No files found.
README.md
View file @
7201ca24
# iot-mqtt-bl
# iot-mqtt-bl
mqtt负载均衡
mqtt负载均衡
\ No newline at end of file
## 定时切换配置文件执行,防止IP封锁
```
shell
crontab
-e
0 1
*
*
1 /path/to/rotate_haproxy_config.sh
```
\ No newline at end of file
haproxy/config/current_config.txt
0 → 100644
View file @
7201ca24
haproxy_config1.cfg
\ No newline at end of file
haproxy/config/haproxy_config1.cfg
0 → 100644
View file @
7201ca24
#HA Proxy Config
global
ulimit-n 500000
maxconn 99999
maxpipes 99999
tune.maxaccept 500
external-check
log 127.0.0.1 local0
log 127.0.0.1 local1 debug
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
ssl-default-bind-options no-sslv3
defaults
log global
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
timeout tunnel 1h # timeout to use with WebSocket and CONNECT
default-server init-addr none
#enable resolving throught docker dns and avoid crashing if service is down while proxy is starting
resolvers docker_resolver
nameserver dns 127.0.0.11:53
listen stats
bind *:9999
stats enable
stats hide-version
stats uri /stats
stats auth admin:admin@123
listen mqtt-in
bind *:${MQTT_PORT}
mode tcp
option clitcpka # For TCP keep-alive
option tcplog
timeout client 3h
timeout server 3h
balance source # 固定服务
option redispatch # 服务出现故障时自动分配
option external-check
option log-health-checks
external-check path "/usr/bin:/bin:/usr/local/bin"
external-check command /usr/local/bin/check_mqtt.sh
server tbMqtt1 47.99.83.75:31883 check inter 120s rise 1 fall 1
server tbMqtt2 47.97.197.103:31883 check inter 120s rise 1 fall 1
server tbMqtt3 47.96.103.209:31883 check inter 120s rise 1 fall 1
#server tbMqtt4 121.43.228.88:31883 check inter 120s rise 1 fall 1
server tbMqtt5 121.43.169.33:31883 check inter 120s rise 1 fall 1
#server tbMqtt6 120.55.38.205:31883 check inter 120s rise 1 fall 1
server tbMqtt7 116.62.229.50:31883 check inter 120s rise 1 fall 1
#server tbMqtt8 121.196.10.235:31883 check inter 120s rise 1 fall 1
#server tbMqtt9 47.114.33.137:31883 check inter 120s rise 1 fall 1
#server tbMqtt10 47.97.181.210:31883 check inter 120s rise 1 fall 1
haproxy/config/haproxy_config2.cfg
0 → 100644
View file @
7201ca24
#HA Proxy Config
global
ulimit-n 500000
maxconn 99999
maxpipes 99999
tune.maxaccept 500
external-check
log 127.0.0.1 local0
log 127.0.0.1 local1 debug
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
ssl-default-bind-options no-sslv3
defaults
log global
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
timeout tunnel 1h # timeout to use with WebSocket and CONNECT
default-server init-addr none
#enable resolving throught docker dns and avoid crashing if service is down while proxy is starting
resolvers docker_resolver
nameserver dns 127.0.0.11:53
listen stats
bind *:9999
stats enable
stats hide-version
stats uri /stats
stats auth admin:admin@123
listen mqtt-in
bind *:${MQTT_PORT}
mode tcp
option clitcpka # For TCP keep-alive
option tcplog
timeout client 3h
timeout server 3h
balance source # 固定服务
option redispatch # 服务出现故障时自动分配
option external-check
option log-health-checks
external-check path "/usr/bin:/bin:/usr/local/bin"
external-check command /usr/local/bin/check_mqtt.sh
#server tbMqtt1 47.99.83.75:31883 check inter 120s rise 1 fall 1
#server tbMqtt2 47.97.197.103:31883 check inter 120s rise 1 fall 1
#server tbMqtt3 47.96.103.209:31883 check inter 120s rise 1 fall 1
server tbMqtt4 121.43.228.88:31883 check inter 120s rise 1 fall 1
#server tbMqtt5 121.43.169.33:31883 check inter 120s rise 1 fall 1
server tbMqtt6 120.55.38.205:31883 check inter 120s rise 1 fall 1
#server tbMqtt7 116.62.229.50:31883 check inter 120s rise 1 fall 1
server tbMqtt8 121.196.10.235:31883 check inter 120s rise 1 fall 1
server tbMqtt9 47.114.33.137:31883 check inter 120s rise 1 fall 1
server tbMqtt10 47.97.181.210:31883 check inter 120s rise 1 fall 1
rotate_haproxy_config.sh
0 → 100755
View file @
7201ca24
#!/bin/bash
CURRENT_CONFIG
=
$(
cat
haproxy/config/current_config.txt
)
if
[
"
$CURRENT_CONFIG
"
==
"haproxy_config1.cfg"
]
;
then
cp
haproxy/config/haproxy_config2.cfg haproxy/config/haproxy.cfg
echo
"haproxy_config2.cfg"
>
haproxy/config/current_config.txt
else
cp
haproxy/config/haproxy_config1.cfg haproxy/config/haproxy.cfg
echo
"haproxy_config1.cfg"
>
haproxy/config/current_config.txt
fi
docker-compose restart haproxy
echo
"HAProxy配置文件已切换为:
$(
cat
haproxy/config/current_config.txt
)
"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment