Set a bandwidth limit for downloads
You can limit the network bandwidth used when sending data to a client. This limit is applied per stream and not at the connection level, meaning that for multiplexed protocols like HTTP/2, where a single connection can simultaneously transfer multiple requests and responses, each of those streams will have its own limit. The limit is expressed in bytes per second.
Use cases for this configuration include:
Setting the maximum download speed for a high-definition video file to be 5 Mbps so that users who have faster connections cannot download faster than that, which would not improve the video quality but could consume bandwidth away from other users.
Setting a more constricted download speed for bots (including search engine crawlers).
To set a download speed limit:
frontendsection where you would like to enable the limit, add a
filter bwlim-outdirective that sets
default-limitparameter sets the number of bytes that can be transferred during the interval defined by
The value 62500, which represents bytes, equals 5Mbps (0.625 megabytes per second = 5 megabits per second).
frontend myfrontend mode http bind :80 filter bwlim-out mylimit default-limit 625000 default-period 1s
http-response set-bandwidth-limitdirective, which enables the filter.
frontend myfrontend mode http bind :80 filter bwlim-out mylimit default-limit 625000 default-period 1s http-response set-bandwidth-limit mylimit
Optional: Edit the
http-response set-bandwidth-limitdirective or add another one to override the bandwidth limit when a given condition is true.
This example uses a map file that contains fingerprints of known or suspected bots in order to set a different bandwidth limit for bot traffic. For information on how to capture fingerprints, see Fingerprint Module and SSL/TLS Fingerprint Module.
frontend myfrontend mode http bind :80 # Sets the normal bandwidth limit for downloads to 5 Mbps filter bwlim-out mylimit default-limit 625000 default-period 1s http-response set-bandwidth-limit mylimit # Overrides the bandwidth limit when we # suspect the client to be a bot http-request set-var(txn.fingerprint_category) req.fingerprint,map_reg(/etc/hapee-2.6/fingerprints.map,'unknown') acl is-bot var(txn.fingerprint_category) -m 'Bot' http-request set-bandwidth-limit mylimit limit int(125000) if is-bot
Next upSet a bandwidth limit for uploads