Skip to content

Commit 848a5fe

Browse files
committed
Added configurable MQTT rate limiting
1 parent 540caec commit 848a5fe

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ requested (this is a multi-value alternative to DOMAINNAME)
2626
* `LE_EXTRA_ARGS` - Can be used to add additional arguments to the certbot command (default `none`)
2727
* `SISH_HOST` - Defines the destination hostname for forwarding requests that begin with `gw-` used in combination with `SISH_PORT`
2828
* `SISH_PORT` - Defined the destination port for forwarding requests tha begin with `gw-` used in combination with `SISH_HOST`
29+
* `MQTT_RATE_LIMIT` - Enable rate limiting for MQTT connections (connections/s)
2930

3031
## Custom certificate format
3132
Any custom certificate volume mapped into `/etc/haproxy/certs` should be in PEM format and must include the full certificate chain and the private key, i.e.:

haproxy.cfg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ frontend https
125125
listen mqtt
126126
bind *:8883 ssl crt /etc/haproxy/certs crt "${CERT_DIR}" no-tls-tickets
127127
mode tcp
128+
129+
.if defined(MQTT_RATE_LIMIT)
130+
# Rate limiting
131+
acl too_fast fe_sess_rate ge ${MQTT_RATE_LIMIT}
132+
tcp-request connection reject if too_fast
133+
.endif
134+
128135
#Use this to avoid the connection loss when client subscribed for a topic and its idle for sometime
129136
option clitcpka # For TCP keep-alive
130137
timeout client 3h #By default TCP keep-alive interval is 2hours in OS kernal, 'cat /proc/sys/net/ipv4/tcp_keepalive_time'

0 commit comments

Comments
 (0)