1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-11-24 02:37:05 +00:00

Changed UFW from Allow to Limit for inbound connection throttling

This commit is contained in:
Chris Blankenship 2016-04-25 19:12:56 -07:00
parent 8548ede638
commit eed360d3e6
4 changed files with 15 additions and 7 deletions

View File

@ -132,6 +132,14 @@ function ufw_allow {
fi fi
} }
# Adds a limit rule allowing 6 in 30 sec
function ufw_limit {
if [ -z "$DISABLE_FIREWALL" ]; then
# ufw has completely unhelpful output
ufw limit $1 > /dev/null;
fi
}
function restart_service { function restart_service {
hide_output service $1 restart hide_output service $1 restart
} }

View File

@ -200,11 +200,11 @@ mkdir -p $STORAGE_ROOT/mail/sieve/global_after
chown -R mail.mail $STORAGE_ROOT/mail/sieve chown -R mail.mail $STORAGE_ROOT/mail/sieve
# Allow the IMAP/POP ports in the firewall. # Allow the IMAP/POP ports in the firewall.
ufw_allow imaps ufw_limit imaps
ufw_allow pop3s ufw_limit pop3s
# Allow the Sieve port in the firewall. # Allow the Sieve port in the firewall.
ufw_allow sieve ufw_limit sieve
# Restart services. # Restart services.
restart_service dovecot restart_service dovecot

View File

@ -229,7 +229,7 @@ if [ -z "$DISABLE_FIREWALL" ]; then
apt_install ufw apt_install ufw
# Allow incoming connections to SSH. # Allow incoming connections to SSH.
ufw_allow ssh; ufw_limit ssh;
# ssh might be running on an alternate port. Use sshd -T to dump sshd's #NODOC # ssh might be running on an alternate port. Use sshd -T to dump sshd's #NODOC
# settings, find the port it is supposedly running on, and open that port #NODOC # settings, find the port it is supposedly running on, and open that port #NODOC
@ -239,7 +239,7 @@ if [ -z "$DISABLE_FIREWALL" ]; then
if [ "$SSH_PORT" != "22" ]; then if [ "$SSH_PORT" != "22" ]; then
echo Opening alternate SSH port $SSH_PORT. #NODOC echo Opening alternate SSH port $SSH_PORT. #NODOC
ufw_allow $SSH_PORT #NODOC ufw_limit $SSH_PORT #NODOC
fi fi
fi fi

View File

@ -106,6 +106,6 @@ restart_service nginx
restart_service php5-fpm restart_service php5-fpm
# Open ports. # Open ports.
ufw_allow http ufw_limit http
ufw_allow https ufw_limit https