To restrict access to your servers so that they are only accessible via a private VPN, you can follow these steps:
-
Set Up a VPN Server: You need to set up a VPN server that your users will connect to. There are several VPN solutions available, such as OpenVPN or WireGuard. You can set up a VPN server on a separate machine or one of your existing servers.
-
Configure VPN Clients: Configure the VPN clients on the devices of the 10 users who need access to the application. They will need to connect to the VPN before they can access any of the servers.
-
Firewall Configuration: Configure the firewall on each of your servers to only allow incoming connections from the VPN's private IP range. This ensures that only devices connected to the VPN can communicate with the servers.
-
Nginx Configuration: If necessary, you can also configure Nginx to only allow requests from the VPN's private IP range. This can be done by updating the server block configuration to include an
allowdirective for the VPN's IP range and deny all others.
Here's an example of how you might configure your Nginx server block:
server {
listen 80;
server_name yourdomain.com;
# Allow only VPN IP addresses
allow 10.8.0.0/24; # Replace with your VPN's private IP range
deny all;
# ... the rest of your configuration
}
-
External API Communication: Since your worker servers need to communicate with external APIs, you should ensure that the VPN configuration allows for outbound connections to the internet. This is typically allowed by default, but you should verify that the VPN's routing and firewall rules do not block these outbound connections.
-
Testing: After setting up the VPN and updating your firewall and Nginx configurations, test the setup thoroughly. Ensure that you can access the application via the VPN and that all external API communications work as expected.
-
Monitoring and Maintenance: Regularly monitor your VPN and server logs to ensure that everything is functioning correctly and that there are no unauthorized access attempts.
Remember to keep your VPN server and all other software up to date with security patches to prevent vulnerabilities.
Here's a basic outline of the steps you would take to set up OpenVPN on a server:
- Install OpenVPN and Easy-RSA.
- Set up the CA directory using Easy-RSA and build the CA.
- Generate server certificates and keys.
- Generate client certificates and keys for each user.
- Configure the OpenVPN server.
- Start the OpenVPN server and enable it to start on boot.
- Distribute client configuration files and certificates to your users.
Please note that setting up a VPN can be complex and may require a good understanding of networking and security. If you're not familiar with these concepts, you might want to consider hiring a professional to ensure that your VPN is secure and configured correctly.