If you are using Plesk, it is highly recommended to manage your security rules through the Plesk interface rather than the server's command line. This ensures that your settings persist after updates and prevents configuration conflicts.
Prerequisites:
- Administrator access to your Plesk panel.
- The Port Number you wish to secure (e.g., 3306 for MySQL, 5432 for PostgreSQL).
- The Trusted IP Address you want to allow.
Steps to Restrict Access:
- Log in to Plesk: Navigate to your Plesk admin URL (usually https://your-server-ip:8443).
- Access Firewall Settings: Go to Tools & Settings in the left-hand menu, then under the Security group, click on Firewall.
- Enable the Firewall: If it’s not already enabled, click Enable Firewall Service.
- Modify Rules: Click on the Modify Plesk Firewall Rules button.
- Add a Custom Rule:
- Click Add Custom Rule.
- Rule Name: Give it a clear name (e.g., “Secure MySQL Access”).
- Direction: Incoming.
- Action: Allow.
- Port: Enter the port number (e.g., 3306).
- Remote Addresses: Select “Add IP address” and enter your trusted IP.
- Apply Changes: Click OK, then click the Apply Changes button at the top of the screen to make the rule active.
Verification:
Try to connect to the service from your allowed IP address. Then, try to connect from a different network (like your mobile data). The connection from the mobile data should be rejected.