How to redirect all traffic on all ports to another server? And also return? I mean, just combine 2 servers on 1 ip. Make one front-end server, and the rest of the server something like a "back end". The application is not a web, it works on different ports.

  • How are you going to tell the server which package to send to the front? - Mike
  • 2 servers, 2 public ip. They need to be connected and refer to one, so that the traffic then goes to the hidden second. - neatek
  • hmm now not yet clearer. You have 2 servers on the Internet, with real ip. when traffic arrives on the first server, do you want to give all traffic to the second? And what role will the first play then? And by the way, are the servers on the same subnet? - Mike
  • @Mike apparently needs to create a "private network", somehow merge the servers into a virtual network, and listen to the port and allow traffic from one server to another within the network. No, not on the same subnet. Just 2 servers separated by country. But it is necessary that only 1 "glow" on the Internet. - neatek
  • Those. the first server will actually only be in the role of a router, i.e. will you handle the traffic yourself (except for overplaying)? Then I think the easiest way is to create an ip-ip tunnel (see ip tunl ) and do iptables ... -j DNAT --to-destination внутренний-ip-на-том-конце-туннеля . On the second server, the return traffic will have to be returned to the first. to do this, create a default route in another routing table (for example, table number 2) ip route add default tab 2 via внутренний-ip-на-туннеле-машины1 and wrap the necessary traffic ip rule add from ip-на-туннеле lookup 2 - in Mike

1 answer 1

It is possible to proxy in nginx:

 server { listen 3333; location / { #ip другой машины в той же приватной сети proxy_pass http://10.1.1.2:3333/; include /etc/nginx/proxy_params; } } 

Or using iptables redirects immediately .

  • that is, any application running on port 3333 will work adequately on another server? let's say this is a mysql server. Does this work?) Iptables tried, did tcp packets come back in theory when specifying such rules? - neatek
  • @neatek should. But there is a little bit different nginx.com/blog/… - Suvitruf
  • interesting ...) and the "private network" between the servers do not tell me how to implement? - neatek
  • @neatek when you pick up the machines, then select one private network. - Suvitruf
  • @neatek is there an option to combine 2 servers on the Internet (in different countries) into one virtual (private) network? - neatek