Openvpn – Forwarding OpenVPN traffic on specific port to different OpenVPN server

openvpnPROXYtunnelingvpn

I am trying to figure out how to setup an OpenVPN server that is able to forward traffic from a specific port to another OpenVPN server at a different location.

I guess this could best be described as an OpenVPN proxy of sorts.

As an example, let's say that I want have an OpenVPN server that I don't want serving HTTP requests, but everything else is okay. I have another server in a different location that I want serving the HTTP requests. The client is only allowed to connect to the first server, so how would I tell the first server to forward all requests on port 80 to the server in the different location?

Best Answer

  1. Make sure the tunnel between the clients and the "proxy" is operating in routed mode.

  2. Make sure the "proxy" is able to reach the services on other servers (through tunnels).

  3. Set up DNAT. Let's say the IP of another server serving port 80 is 172.16.76.1:

iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to 172.16.76.1

Alternatively, run a proxy of some sorts: balance, haproxy, nginx, whatever, depending on protocol and use case.

  1. Make sure the clients are accessing the service on a tunneled (secured) IP.