CWP (CentOS Web Panel) is powerful but not secure by default. If you leave it as-is, it will get attacked.
Hereβs a practical hardening guide:
π 1. Change Default Ports (VERY IMPORTANT)
CWP runs on:
2030(HTTP)2031(HTTPS)
π Bots scan these ports constantly.
Change it:
Edit config:
vi /usr/local/cwpsrv/conf/cwpsrv.conf
Change:
listen 2031 ssl;
β‘οΈ Example:
listen 2087 ssl;
Then restart:
service cwpsrv restart
π 2. Enable Firewall (CSF) Properly
CWP comes with CSF (ConfigServer Firewall)
Go to:
π CWP β Security β CSF Firewall
Recommended:
- Enable TESTING = 0
- Enable:
- SYN Flood Protection
- Port Scan Tracking
- Connection Tracking
Allow only needed ports:
22 (SSH)
80 (HTTP)
443 (HTTPS)
YOUR NEW CWP PORT
π« 3. Disable Root Login (SSH)
Edit:
vi /etc/ssh/sshd_config
Change:
PermitRootLogin no
Restart:
systemctl restart sshd
π Create a sudo user instead.
π 4. Use SSH Key (No Password Login)
vi /etc/ssh/sshd_config
Set:
PasswordAuthentication no
π This alone blocks 90% of brute-force attacks.
π§± 5. Enable ModSecurity + OWASP Rules
Go to:
π CWP β Security β ModSecurity
Enable:
- ModSecurity = ON
- OWASP rules = ON
π Protects against:
- SQL injection
- XSS
- common exploits
π 6. Restrict CWP Access by IP (BEST MOVE)
If only you use the panel:
Allow only your IP:
In CSF:
csf -a YOUR_IP
Then block panel port for others.
π This is one of the strongest protections.
π 7. Keep System Updated
yum update -y
And update CWP:
sh /scripts/update_cwp
π‘οΈ 8. Install Fail2Ban (Extra Layer)
yum install fail2ban -y
systemctl enable fail2ban
systemctl start fail2ban
π Protects:
- SSH
- login brute force
π 9. Secure PHP & Disable Dangerous Functions
Edit php.ini:
vi /usr/local/php/php.ini
Disable:
exec,passthru,shell_exec,system,proc_open,popen
π 10. Fix File Permissions
chmod 755 /home/*
chmod 644 public_html files
π 11. SSL for Panel
Make sure you use:
https://your-ip:PORT
π You can install Letβs Encrypt inside CWP panel.
π¨ 12. Change Default Login URL (Optional but smart)
Use firewall rules to restrict /login access or proxy it.
π‘ Bonus (Highly Recommended)
- Disable unused services:
systemctl disable ftp
- Remove unused PHP versions
- Monitor logs:
/var/log/secure
β Minimum Must-Do Checklist
If you do nothing else, do these 5:
β Change port
β Enable CSF firewall
β Disable root SSH
β Use SSH key
β Restrict IP access