To secure publicly accessible services on your Hostinger VPS, bind databases and caches to localhost, hide web server version details, disable weak SSL/TLS protocols and ciphers, replace weak credentials, restrict mail relaying, and enable the firewall. MySQL, PostgreSQL, Redis, and web servers may be configured to accept connections from any IP address, which creates security risks.
Database vulnerabilities
MySQL
Issue: MySQL is accepting connections from all IP addresses (0.0.0.0)
Solution:
- Open the MySQL configuration file:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf - Update the bind address:
bind-address = 127.0.0.1 - Restart the service:
sudo systemctl restart mysql
PostgreSQL
Issue: PostgreSQL is listening on all network interfaces
Solution:
- Edit the PostgreSQL configuration:
sudo nano /etc/postgresql/*/main/postgresql.conf - Update the listen addresses:
listen_addresses = 'localhost' - Restart the service:
sudo systemctl restart postgresql
MongoDB
Issue: MongoDB is publicly accessible
Solution:
- Edit the MongoDB configuration:
sudo nano /etc/mongod.conf - Update the network binding:
net: bindIp: 127.0.0.1 - Restart the service:
sudo systemctl restart mongod
Redis
Issue: Redis is bound to all interfaces
Solution:
- Open the Redis configuration:
sudo nano /etc/redis/redis.conf - Update the bind address:
bind 127.0.0.1 - Ensure protected mode is enabled:
protected-mode yes - Restart the service:
sudo systemctl restart redis
Search and caching services
Elasticsearch
Issue: Elasticsearch is accepting external connections
Solution:
- Edit the Elasticsearch configuration:
sudo nano /etc/elasticsearch/elasticsearch.yml - Set the network host:
network.host: 127.0.0.1 - Restart the service:
sudo systemctl restart elasticsearch
Memcached
Issue: Memcached is listening on all interfaces
Solution:
- Edit the Memcached configuration:
sudo nano /etc/memcached.conf - Update the listen address:
-l 127.0.0.1 - Restart the service:
sudo systemctl restart memcached
Web server vulnerabilities
HTTP server information disclosure
Issue: Web server is exposing version information and sensitive details
Apache
- Edit the security configuration:
sudo nano /etc/apache2/conf-available/security.conf - Add or update:
ServerTokens Prod ServerSignature Off - Disable directory listing:
<Directory /var/www/> Options -Indexes </Directory> - Restart Apache:
sudo systemctl restart apache2
Nginx
- Edit the Nginx configuration:
sudo nano /etc/nginx/nginx.conf - Add inside the http block:
server_tokens off; - Restart Nginx:
sudo systemctl restart nginx
SSL/TLS vulnerabilities
POODLE vulnerability (SSLv3)
Issue: Server allows vulnerable SSLv3 protocol
Apache
- Edit SSL configuration:
sudo nano /etc/apache2/mods-available/ssl.conf - Update SSL protocols:
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1 - Restart Apache:
sudo systemctl restart apache2
Nginx
- Edit site configuration:
sudo nano /etc/nginx/sites-available/default - Add or update in server block:
ssl_protocols TLSv1.2 TLSv1.3; - Restart Nginx:
sudo systemctl restart nginx
FREAK vulnerability (weak ciphers)
Issue: Server allows weak export-grade cipher suites
Apache
- Edit SSL configuration:
sudo nano /etc/apache2/mods-available/ssl.conf - Update cipher suite:
SSLCipherSuite HIGH:!aNULL:!MD5:!EXP:!LOW:!MEDIUM - Restart Apache:
sudo systemctl restart apache2
Nginx
- Edit site configuration:
sudo nano /etc/nginx/sites-available/default - Add or update:
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384'; ssl_prefer_server_ciphers on; - Restart Nginx:
sudo systemctl restart nginx
Authentication and secrets
Bad secrets / weak credentials
Issue: Default credentials, weak passwords, or exposed secrets detected
Database credentials
Change MySQL user password:
mysql -u root -pALTER USER 'username'@'localhost' IDENTIFIED BY 'NewStrongPassword123!';
FLUSH PRIVILEGES;Environment files
- Find exposed .env files:
sudo find /var/www -name ".env" -type f - Secure permissions:
sudo chmod 600 /var/www/your-site/.env
Best practices
- Use passwords with minimum 12 characters
- Include uppercase, lowercase, numbers, and symbols
- Rotate API keys regularly
- Use a password manager
Mail server security
SMTP open relay / authentication issues
Issue: Mail server may be configured as an open relay or lacks proper authentication
Postfix
- Edit the configuration:
sudo nano /etc/postfix/main.cf - Add or update:
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination smtpd_tls_security_level = may smtpd_tls_auth_only = yes - Restart Postfix:
sudo systemctl restart postfix
Exim
- Edit the configuration:
sudo nano /etc/exim4/update-exim4.conf.conf - Update relay networks:
dc_relay_nets='127.0.0.1' - Apply changes:
sudo update-exim4.conf sudo systemctl restart exim4
Firewall configuration
Additional security layer
Allow SSH and enable firewall:
sudo ufw allow ssh
sudo ufw enableAllow remote access from trusted IP only:
sudo ufw allow from <YOUR_IP> to any port 3306Verification
Test SSL/TLS configuration
Visit: https://www.ssllabs.com/ssltest/
Check open ports
sudo netstat -tulnReview active services
sudo systemctl list-units --type=service --state=runningYour publicly accessible services are now restricted to the connections you allow, and the checks above confirm which ports and services are running.