I have a hosted linux server with public IP address. I would like to configure it as a VPN server. Then I would like to hide all of its services behind this VPN, so that if I open a socket then by default it is accessible through VPN and not accessible via Internet.
Is it possible?
Attach the services to the interface/ip of the VPN. To make ssh only listen to the VPN-ip change the "sshd_config":
Same with apache and so on..
You could also firewall the public ip and only allow on the VPN.
Iptables is helpfull !
for example, with an openvpn run on eth0 interface, with 1194 tcp port and your vpn interface is "tun0"
So, you can set your filter (rules 3) with you vpn adresses, or an other vpn interface (ipsec0, gre, tap etc..)
Of course, just set up iptables rules appropriately.