- 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 & Settingsand then toIP Address Banning (Fail2Ban) - Click on the
Settingstab and then select theEnable intrusion detectioncheckbox - 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
Applybutton - Click on the
Jailstab - Select all the jails that you want to enable and then click on the
Switch Onbutton - Click on the
OKbutton
- If not already installed, install ModSecurity
sudo plesk installer --select-release-current --install-component modsecurity
- Go to
Tools & Settingsand then toWeb Application Firewall (ModSecurity) - Click on the
Generaltab - Select the
Oncheckbox right to theWeb application firewall modesection - Click on the
Settingstab - Under the
Rule setssection select theAtomic Basic ModSecurityradio button - Select the
Update rule setscheckbox and define aDailyupdate in the select - Under the
Configurationsection select theTradeoffradio button - Click on the
Applybutton - Click on the
OKbutton
- Connect to the server thru SSH
- Edit the /etc/proftpd.conf file
sudo vi /etc/proftpd.conf- Insert the following line inside the
Globalsection
<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 > Firewalland click on theEnable Firewall Rules Managementbutton, and then click on theEnablebutton. - Once changes are applied, click on the
Modify Plesk Firewall Rulesbutton and then on theAdd Custom Ruleone. - 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
Addbutton - Click on the
OKbutton
- Click on the
Apply Changesbutton - Click on the
Activatebutton - 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
httpsection
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;