Score:0

Proxy all requests from one machine to another using nginx or anything else

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!

Reishin avatar
sa flag
why do you need NGINX or proxy? just route the traffic through VPN
Михаил Агафонов avatar
@Reishin, thank you for your reply, i think routing is what I am looking for. Could you please describe a little more detailed about how i can route all incoming traffic to specific ip (e.g. 10.8.0.5)?
bjoster avatar
cn flag
How to you want to connect (and configure) your VPS, when ALL connections are forwarded?
Score:0
cn flag

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.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.