By Chris Taylor
Mr
I have a web application running on a Droplet, under Apache. The application is currently public.
I would now like to configure a VPN, to restrict access. I would then expect users of the application to gain access via VPN client software only.
How can I restrict my server application to a VPN?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
To restrict your web application to VPN access only, follow these steps:
1.Set Up a VPN: Install and configure a VPN server on your Droplet (e.g., OpenVPN, WireGuard).
2.Configure Firewall Rules: Use firewall rules (e.g., UFW, iptables) to allow traffic only from the VPN network. Block public access to your web application port (typically port 80 or 443 for HTTP/HTTPS).
3.Update Apache Configuration: Modify your Apache configuration to listen only on the VPN network interface. This ensures that Apache serves your application only to VPN-connected clients.
4.Distribute VPN Credentials: Provide VPN client configuration files and credentials to authorized users.
By following these steps, only users connected to your VPN will be able to access your web application.
Heya,
you’ll need to set up a VPN server on your Droplet and configure your Apache server to allow connections only from the VPN.
You can check this MarketPlace Droplet:
https://marketplace.digitalocean.com/apps/openvpn-access-server
Follow the steps on that page to configure a Droplet with OpenVPN on it.
Once you have that you’ll need to restrict access on the Droplet your App is only from the VPN.
Edit Apache Configuration:
Open your Apache configuration file, usually located at /etc/apache2/sites-available/000-default.conf
or similar.
Restrict Access:
Add a Require
directive to restrict access to the IP range used by your VPN. For example:
<Directory /var/www/html>
Require ip 10.0.0.0/24
</Directory>
This allows access only to clients connected to the VPN using the IP range 10.0.0.0/24
.
sudo systemctl restart apache2
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.