For work, I had to use an OpenVPN server to access a few websites since they only allow the IP address from the work OpenVPN server. However, I still want to use the IP address of my own OpenVPN server to access most websites (my VPN is installed on a VPS Linux server). Currently I am able to turn the OpenVPN server that I use for work into a SOCKS proxy by using an SSH tunnel to an LXC container which has an OpenVPN client (instead of LXC, it could also be done with a Linux virtual machine in VirtualBox but the performance is better with LXC). I also created a SOCKS proxy by using an SSH tunnel to my own Linux server, in order to be able to use 2 Firefox profiles connecting to a different proxy, one for personal browsing and the other for work browsing.
The OpenVPN server that I use for work only allows browsing a few websites, so it is pushing the allowed routes instead of using a default gateway that will route all traffic through the VPN. When I use this VPN connection, a privacy issue is that it will leak my real IP address to all third-party requests of the work websites. If these third-party requests are using HTTP instead of HTTPS, there is also a risk of man-in-the-middle attack on the local network, which is a security issue due to the VPN not routing all Internet traffic. The other privacy issue is that my real IP address is leaked when connecting to the OpenVPN server that I have to use for work.
Is it possible to fix these security and privacy issues by using a proxy or another VPN before connecting to a VPN?
I tried to connect to the 2 VPNs at the same time but the work website was not working.
I also tried redsocks to have a SOCKS proxy system-wide and then connect to the work OpenVPN server but the work website was not working either.
I tried proxychains too. And I heard there is a
socks-proxy variable that can be configured in the OpenVPN client file but I did not get it working, maybe because the OpenVPN server is using UDP instead of TCP, which is not supported by a SOCKS proxy using an SSH tunnel.
Update: I partially fixed the problem by using a route like
ip route add WORK_VPN_IP via GATEWAY_IP which allows to use the 2 VPNs at the same time. In the LXC container, I can now use the work VPN for work websites and use my own VPN for all other websites or third-party requests. However I think this will still leak my real IP address to the work VPN. By using the traceroute command on a work domain name, I can see that the traffic only goes through my work VPN.
Using my own VPN outside of the LXC container and using the work VPN inside the LXC container does not even make it possible to access HTTPS websites through the work VPN (https://askubuntu.com/questions/703905/unable-to-open-sites-with-https-when-connected-through-openvpn/1206914#1206914). Instead of using an LXC container, I also tested using a virtual machine with NAT network in VirtualBox. The HTTPS problem also happens with a script like VPN-Chain (https://github.com/TensorTom/VPN-Chain/issues/7).
A solution would be to connect directly to the work VPN on my Linux server but I don't want to enter work VPN credentials in the cloud for security reasons (it could also mess the routing of my own VPN installed in this Linux server).
Update 2: I installed Dante SOCKS proxy on my server and I am now able to connect to my proxy before the work VPN, by using the
socks-proxy variable in the OpenVPN client config file. This solves my problem but I would still be interested to know if it is possible to connect to a VPN instead of a proxy before connecting to another VPN, without the problem I had with HTTPS websites.
Update 3: I was able to solve the problem by adding