Created
May 30, 2024 23:03
-
-
Save solaceten/c1dca615f355514c637e646485610c7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Setting up mod_ratelimit on cPanel Server | |
# Provides additional stability on the server by rate limiting bandwidth, thereby slowing down connections and helping to stabilise server | |
# Useful help: https://usavps.com/blog/13241/ | |
# Useful help: https://httpd.apache.org/docs/2.4/mod/mod_ratelimit.html | |
# Useful help: https://maj0rmil4d.medium.com/how-to-limit-bandwidth-per-connection-on-apache-ratelimit-d59e8057ca7b | |
# 1) Check you have installed modules via easyapache; mod_ratelimit and mod_env | |
# 2) go to WHM > Apach config > include editor > pre-virtual hosts | |
# Add the following - if specific vhost, use just their domain e.g. example.com | |
#+++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
#check mod rate_limit is up and running | |
<IfModule mod_ratelimit.c> | |
# target yourdomain.com specific domain | |
# allow burst of up to 1024 mb/s, then slow to 512 | |
<VirtualHost yourdomain.com:443> | |
<Location /> | |
SetOutputFilter RATE_LIMIT | |
SetEnv rate-initial-burst 1024 | |
SetEnv rate-limit 512 | |
</Location> | |
</VirtualHost> | |
# target all other domains | |
<VirtualHost _default_:*> | |
<Location /> | |
SetOutputFilter RATE_LIMIT | |
#SetEnv rate-initial-burst 1024 | |
SetEnv rate-limit 1024 | |
</Location> | |
</VirtualHost> | |
</IfModule> | |
#Test the download speed: | |
# example: | |
# root> curl -o /dev/null -w "Transfer speed: %{speed_download} bytes/sn" https://yourdomain.com | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment