{"id":6258,"date":"2025-10-29T10:36:42","date_gmt":"2025-10-29T10:36:42","guid":{"rendered":"https:\/\/www.hostinger.com\/support\/?p=6258"},"modified":"2026-03-05T16:42:49","modified_gmt":"2026-03-05T16:42:49","slug":"securing-publicly-accessible-services-on-your-vps","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/support\/securing-publicly-accessible-services-on-your-vps\/","title":{"rendered":"Securing Publicly Accessible Services on Your VPS"},"content":{"rendered":"<h3>Overview<\/h3><p>This guide covers how to secure services and fix common vulnerabilities detected on your VPS. Services like MySQL, PostgreSQL, Redis, and web servers may be configured to accept connections from any IP address, creating security risks.<\/p><hr><h2 id=\"h-database-vulnerabilities\">Database Vulnerabilities<\/h2><h3 id=\"mysql\">MySQL<\/h3><p><strong>Issue:<\/strong> MySQL is accepting connections from all IP addresses (0.0.0.0)<\/p><p><strong>Solution:<\/strong><\/p><p>1. Open the MySQL configuration file:<\/p><pre><code>sudo nano \/etc\/mysql\/mysql.conf.d\/mysqld.cnf<\/code><\/pre><p>2. Update the bind address:<\/p><pre><code>bind-address = 127.0.0.1<\/code><\/pre><p>3. Restart the service:<\/p><pre><code>sudo systemctl restart mysql<\/code><\/pre><hr><h3 id=\"postgresql\">PostgreSQL<\/h3><p><strong>Issue:<\/strong> PostgreSQL is listening on all network interfaces<\/p><p><strong>Solution:<\/strong><\/p><p>1. Edit the PostgreSQL configuration:<\/p><pre><code>sudo nano \/etc\/postgresql\/*\/main\/postgresql.conf<\/code><\/pre><p>2. Update the listen addresses:<\/p><pre><code>listen_addresses = 'localhost'<\/code><\/pre><p>3. Restart the service:<\/p><pre><code>sudo systemctl restart postgresql<\/code><\/pre><hr><h3 id=\"mongodb\">MongoDB<\/h3><p><strong>Issue:<\/strong> MongoDB is publicly accessible<\/p><p><strong>Solution:<\/strong><\/p><p>1. Edit the MongoDB configuration:<\/p><pre><code>sudo nano \/etc\/mongod.conf<\/code><\/pre><p>2. Update the network binding:<\/p><pre><code>net:\r\n  bindIp: 127.0.0.1<\/code><\/pre><p>3. Restart the service:<\/p><pre><code>sudo systemctl restart mongod<\/code><\/pre><hr><h3 id=\"redis\">Redis<\/h3><p><strong>Issue:<\/strong> Redis is bound to all interfaces<\/p><p><strong>Solution:<\/strong><\/p><p>1. Open the Redis configuration:<\/p><pre><code>sudo nano \/etc\/redis\/redis.conf<\/code><\/pre><p>2. Update the bind address:<\/p><pre><code>bind 127.0.0.1<\/code><\/pre><p>3. Ensure protected mode is enabled:<\/p><pre><code>protected-mode yes<\/code><\/pre><p>4. Restart the service:<\/p><pre><code>sudo systemctl restart redis<\/code><\/pre><hr><h2 id=\"h-search-and-caching-services\">Search and Caching Services<\/h2><h3 id=\"elasticsearch\">Elasticsearch<\/h3><p><strong>Issue:<\/strong> Elasticsearch is accepting external connections<\/p><p><strong>Solution:<\/strong><\/p><p>1. Edit the Elasticsearch configuration:<\/p><pre><code>sudo nano \/etc\/elasticsearch\/elasticsearch.yml<\/code><\/pre><p>2. Set the network host:<\/p><pre><code>network.host: 127.0.0.1<\/code><\/pre><p>3. Restart the service:<\/p><pre><code>sudo systemctl restart elasticsearch<\/code><\/pre><hr><h3 id=\"memcached\">Memcached<\/h3><p><strong>Issue:<\/strong> Memcached is listening on all interfaces<\/p><p><strong>Solution:<\/strong><\/p><p>1. Edit the Memcached configuration:<\/p><pre><code>sudo nano \/etc\/memcached.conf<\/code><\/pre><p>2. Update the listen address:<\/p><pre><code>-l 127.0.0.1<\/code><\/pre><p>3. Restart the service:<\/p><pre><code>sudo systemctl restart memcached<\/code><\/pre><hr><h2 id=\"h-web-server-vulnerabilities\">Web Server Vulnerabilities<\/h2><h3 id=\"http\">HTTP Server Information Disclosure<\/h3><p><strong>Issue:<\/strong> Web server is exposing version information and sensitive details<\/p><h4>Apache<\/h4><p>1. Edit the security configuration:<\/p><pre><code>sudo nano \/etc\/apache2\/conf-available\/security.conf<\/code><\/pre><p>2. Add or update:<\/p><pre><code>ServerTokens Prod\r\nServerSignature Off<\/code><\/pre><p>3. Disable directory listing:<\/p><pre><code>&lt;Directory \/var\/www\/&gt;\r\n    Options -Indexes\r\n&lt;\/Directory&gt;<\/code><\/pre><p>4. Restart Apache:<\/p><pre><code>sudo systemctl restart apache2<\/code><\/pre><h4>Nginx<\/h4><p>1. Edit the Nginx configuration:<\/p><pre><code>sudo nano \/etc\/nginx\/nginx.conf<\/code><\/pre><p>2. Add inside the http block:<\/p><pre><code>server_tokens off;<\/code><\/pre><p>3. Restart Nginx:<\/p><pre><code>sudo systemctl restart nginx<\/code><\/pre><hr><p>&lt;h2&Prime;&gt;SSL\/TLS Vulnerabilities<\/p><h3 id=\"poodle-vulnerability\">POODLE Vulnerability (SSLv3)<\/h3><p><strong>Issue:<\/strong> Server allows vulnerable SSLv3 protocol<\/p><h4>Apache<\/h4><p>1. Edit SSL configuration:<\/p><pre><code>sudo nano \/etc\/apache2\/mods-available\/ssl.conf<\/code><\/pre><p>2. Update SSL protocols:<\/p><pre><code>SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1<\/code><\/pre><p>3. Restart Apache:<\/p><pre><code>sudo systemctl restart apache2<\/code><\/pre><h4>Nginx<\/h4><p>1. Edit site configuration:<\/p><pre><code>sudo nano \/etc\/nginx\/sites-available\/default<\/code><\/pre><p>2. Add or update in server block:<\/p><pre><code>ssl_protocols TLSv1.2 TLSv1.3;<\/code><\/pre><p>3. Restart Nginx:<\/p><pre><code>sudo systemctl restart nginx<\/code><\/pre><hr><h3 id=\"freak-vulnerability\">FREAK Vulnerability (Weak Ciphers)<\/h3><p><strong>Issue:<\/strong> Server allows weak export-grade cipher suites<\/p><h4>Apache<\/h4><p>1. Edit SSL configuration:<\/p><pre><code>sudo nano \/etc\/apache2\/mods-available\/ssl.conf<\/code><\/pre><p>2. Update cipher suite:<\/p><pre><code>SSLCipherSuite HIGH:!aNULL:!MD5:!EXP:!LOW:!MEDIUM<\/code><\/pre><p>3. Restart Apache:<\/p><pre><code>sudo systemctl restart apache2<\/code><\/pre><h4>Nginx<\/h4><p>1. Edit site configuration:<\/p><pre><code>sudo nano \/etc\/nginx\/sites-available\/default<\/code><\/pre><p>2. Add or update:<\/p><pre><code>ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384';\r\nssl_prefer_server_ciphers on;<\/code><\/pre><p>3. Restart Nginx:<\/p><pre><code>sudo systemctl restart nginx<\/code><\/pre><hr><h2 id=\"h-authentication-and-secrets\">Authentication and Secrets<\/h2><h3>Bad Secrets \/ Weak Credentials<\/h3><p><strong>Issue:<\/strong> Default credentials, weak passwords, or exposed secrets detected<\/p><h4 id=\"database-credentials\">Database Credentials<\/h4><p>Change MySQL user password:<\/p><pre><code>mysql -u root -p<\/code><\/pre><pre><code>ALTER USER 'username'@'localhost' IDENTIFIED BY 'NewStrongPassword123!';\r\nFLUSH PRIVILEGES;<\/code><\/pre><h4>Environment Files<\/h4><p>1. Find exposed .env files:<\/p><pre><code>sudo find \/var\/www -name \".env\" -type f<\/code><\/pre><p>2. Secure permissions:<\/p><pre><code>sudo chmod 600 \/var\/www\/your-site\/.env<\/code><\/pre><h4>Best Practices<\/h4><ul>\n<li>Use passwords with minimum 12 characters<\/li>\n<li>Include uppercase, lowercase, numbers, and symbols<\/li>\n<li>Rotate API keys regularly<\/li>\n<li>Use a password manager<\/li>\n<\/ul><hr><h2 id=\"h-mail-server-security\">Mail Server Security<\/h2><h3 id=\"smtp-open-relay\">SMTP Open Relay \/ Authentication Issues<\/h3><p><strong>Issue:<\/strong> Mail server may be configured as an open relay or lacks proper authentication<\/p><h4>Postfix<\/h4><p>1. Edit the configuration:<\/p><pre><code>sudo nano \/etc\/postfix\/main.cf<\/code><\/pre><p>2. Add or update:<\/p><pre><code>smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination\r\nsmtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination\r\nsmtpd_tls_security_level = may\r\nsmtpd_tls_auth_only = yes<\/code><\/pre><p>3. Restart Postfix:<\/p><pre><code>sudo systemctl restart postfix<\/code><\/pre><h4>Exim<\/h4><p>1. Edit the configuration:<\/p><pre><code>sudo nano \/etc\/exim4\/update-exim4.conf.conf<\/code><\/pre><p>2. Update relay networks:<\/p><pre><code>dc_relay_nets='127.0.0.1'<\/code><\/pre><p>3. Apply changes:<\/p><pre><code>sudo update-exim4.conf\r\nsudo systemctl restart exim4<\/code><\/pre><hr><h2 id=\"firewall-configuration\">Firewall Configuration<\/h2><h3>Additional Security Layer<\/h3><p>Allow SSH and enable firewall:<\/p><pre><code>sudo ufw allow ssh\r\nsudo ufw enable<\/code><\/pre><p>Allow remote access from trusted IP only:<\/p><pre><code>sudo ufw allow from &lt;YOUR_IP&gt; to any port 3306<\/code><\/pre><hr><h2 id=\"h-verification\">Verification<\/h2><h3>Test SSL\/TLS Configuration<\/h3><p>Visit: <a href=\"https:\/\/www.ssllabs.com\/ssltest\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.ssllabs.com\/ssltest\/<\/a><\/p><h3>Check Open Ports<\/h3><pre><code>sudo netstat -tuln<\/code><\/pre><h3>Review Active Services<\/h3><pre><code>sudo systemctl list-units --type=service --state=running<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>OverviewThis guide covers how to secure services and fix common vulnerabilities detected on your VPS. Services like MySQL, PostgreSQL, Redis, and web servers may be&#8230;<\/p>\n","protected":false},"author":568,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"include_on_kodee":true,"footnotes":""},"categories":[199],"tags":[],"class_list":["post-6258","post","type-post","status-publish","format-standard","hentry","category-vps-management"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/support\/securing-publicly-accessible-services-on-your-vps","default":1}],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/6258","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/users\/568"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/comments?post=6258"}],"version-history":[{"count":12,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/6258\/revisions"}],"predecessor-version":[{"id":6381,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/6258\/revisions\/6381"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/media?parent=6258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/categories?post=6258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/tags?post=6258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}