- Ban IP Addresses and Networks (Fail2ban)
- Web Application Firewall (ModSecurity)
- Configure FTP passive ports (ProFTPd)
- Harden Nginx
- If not already installed, install Fail2ban
sudo plesk installer --select-release-current --install-component fail2ban
- Go to
Tools & Settings
and then toIP Address Banning (Fail2Ban)
- Click on the
Settings
tab and then select theEnable intrusion detection
checkbox - Set the settings that suit your needs:
- IP address ban period: time interval in seconds for which an IP address is banned. When this period is over, the IP address is automatically unbanned
- Time interval for detection of subsequent attacks: time interval in seconds during which the system counts the number of unsuccessful login attempts and other unwanted actions from an IP address
- Number of failures before the IP address is banned: number of failed login attempts from the IP address
- Click on the
Apply
button - Click on the
Jails
tab - Select all the jails that you want to enable and then click on the
Switch On
button - Click on the
OK
button
- If not already installed, install ModSecurity
sudo plesk installer --select-release-current --install-component modsecurity
- Go to
Tools & Settings
and then toWeb Application Firewall (ModSecurity)
- Click on the
General
tab - Select the
On
checkbox right to theWeb application firewall mode
section - Click on the
Settings
tab - Under the
Rule sets
section select theAtomic Basic ModSecurity
radio button - Select the
Update rule sets
checkbox and define aDaily
update in the select - Under the
Configuration
section select theTradeoff
radio button - Click on the
Apply
button - Click on the
OK
button
- Connect to the server thru SSH
- Edit the /etc/proftpd.conf file
sudo vi /etc/proftpd.conf
- Insert the following line inside the
Global
section
<Global>
...
PassivePorts 30000 31000
</Global>
- If not already installed, install Plesk Firewall
sudo plesk installer --select-release-current --install-component psa-firewall
- If not already enabled, enable Plesk Firewall
Tools & Settings > Firewall
and click on theEnable Firewall Rules Management
button, and then click on theEnable
button. - Once changes are applied, click on the
Modify Plesk Firewall Rules
button and then on theAdd Custom Rule
one. - Specify the following information in the web form:
- Name of the rule: FTP Passive Ports
- Match direction: Incoming
- Action: Allow
- Add port or port range: set passive ports range specified in /etc/proftpd.conf, for example 30000-31000 and leave the TCP option selected, then click the
Add
button - Click on the
OK
button
- Click on the
Apply Changes
button - Click on the
Activate
button - Test your configuration
- Connect to the server thru SSH
- Edit the /etc/nginx/nginx.conf file
sudo vi /etc/nginx/nginx.conf
- Insert the following line in the
http
section
http {
...
# avoid sending Nginx version number in error pages and server header
server_tokens off;
...
}
- Save the file and test Nginx configuration
sudo nginx -t
- Restart Nginx Web server for the changes to take effect
sudo systemctl restart nginx
- Connect to the server thru SSH
- Edit the /etc/nginx/conf.d/ssl.conf file
sudo vi /etc/nginx/conf.d/ssl.conf
- Replace the content with the following lines
# Enable only secure cipher suites
ssl_ciphers EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH;
# Disable SSL 3, TLSv1, and TLSv1.1
ssl_protocols TLSv1.2 TLSv1.3;
# Server ciphers should be preferred over client ciphers when using TLS protocols
ssl_prefer_server_ciphers on;
# Enable session reuse to improve https performance
ssl_session_cache shared:SSL:60m;
ssl_session_timeout 1d;
ssl_session_tickets off;
- Save the file and test Nginx configuration
sudo nginx -t
- Restart Nginx Web server for the changes to take effect
sudo systemctl restart nginx
- Connect to the server thru SSH
- Create the gzip.conf file
sudo touch /etc/nginx/conf.d/gzip.conf
- Insert the following lines
gzip on;
gzip_disable "MSIE [1-6]\\.(?!.*SV1)";
gzip_proxied any;
gzip_comp_level 5;
gzip_types text/plain text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp image/svg+xml;
gzip_vary on;