0

Is it possible to proxy all requests to another server saving corresponding ports and protocols?

I have a homeserver (without public ip) and VDS (with public ip).
I also established connection between them using VPN (openVPN).
So now, my homeserver has 10.8.0.5 ip address in virtual network.

So i am looking for an opportunity to proxy all requests coming to the VDS to homeserver (through nginx or any another way)

For instance:

  • proxy ssh connections:
    port: 22
    protocol: TCP
    should be proxied to port 22 using protocol TCP
  • proxy http requests:
    port: 80
    protocol: HTTP
    should be proxied to port 80 using protocol HTTP
  • proxy specific requests:
    port: ANY PORT
    protocol: ANY PROTOCOL
    should be proxied to the same port using the same protocol

Is it possible? And if yes, how can i bring it into life? Which tools can I use?

Thank you!

1 Answers1

0

If I understand your description and comment correctly, you will want to do a DNAT (Destination Network Address Translation ... also called port-forwarding) on all ports so inbound traffic (with destination address of the server itself) is port-forwarded to 10.8.0.5. That's easily accomplished in the iptables nat table.

iptables --table nat --append PREROUTING --jump DNAT --to-destination 10.8.0.5

If you need to allow some connectivity to the server itself, place other rules allowing it before this one, as explained in your other post "Route all traffic (except port 3336 and a few more) from eth0 to specific ip" on the same topic, referring to this post.

fraxflax
  • 76
  • 6